Skip to content

Commit

Permalink
Upgrade to hawkular-parent 38 and Cassandra 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Mar 10, 2016
1 parent cf371ca commit ddccbb0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 620 deletions.
6 changes: 6 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
<artifactId>hawkular-accounts-common</artifactId>
<version>2.0.23.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.hawkular.commons</groupId>
<artifactId>hawkular-commons-embedded-cassandra-service</artifactId>
<version>${version.org.hawkular.commons}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.2_spec</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Collectors;

import javax.enterprise.inject.Instance;

import org.apache.cassandra.service.EmbeddedCassandraService;
import org.apache.thrift.transport.TTransportException;
import org.hawkular.accounts.api.internal.ApplicationResources;
import org.hawkular.accounts.api.internal.BoundStatements;
import org.hawkular.accounts.api.model.Role;
import org.hawkular.accounts.common.ZonedDateTimeAdapter;
import org.hawkular.commons.cassandra.EmbeddedCassandraService;
import org.hawkular.commons.cassandra.EmbeddedConstants;
import org.junit.Before;

import com.datastax.driver.core.BoundStatement;
Expand Down Expand Up @@ -228,27 +231,36 @@ private void startServerIfNotRunning() throws IOException, TTransportException,
try {
session = new Cluster.Builder()
.addContactPoints("localhost")
.withPort(9042)
.withProtocolVersion(ProtocolVersion.V3)
.build().connect();
} catch (NoHostAvailableException e) {
String cassandraYmlLocation = findPathForCassandraYaml("./cassandra.yml");
if (null == cassandraYmlLocation || cassandraYmlLocation.isEmpty()) {
cassandraYmlLocation = findPathForCassandraYaml("./api/target/test-classes/cassandra.yml");
}

if (null == cassandraYmlLocation || cassandraYmlLocation.isEmpty()) {
throw new IllegalArgumentException("Could not find a cassandra.yml");
}

System.setProperty("cassandra.config", "file://" + cassandraYmlLocation);
Path tmpDir = Files.createTempDirectory("hawkular-accounts-api-cassandra");
System.setProperty(EmbeddedConstants.JBOSS_DATA_DIR, tmpDir.toAbsolutePath().toString());
System.setProperty(EmbeddedConstants.HAWKULAR_BACKEND_PROPERTY,
EmbeddedConstants.EMBEDDED_CASSANDRA_OPTION);
EmbeddedCassandraService service = new EmbeddedCassandraService();
service.start();

session = new Cluster.Builder()
.addContactPoints("localhost")
.withPort(9142)
.withProtocolVersion(ProtocolVersion.V3)
.build().connect();
NoHostAvailableException lastException = null;
final int timeoutSeconds = 60;
for (int i = 0; i < timeoutSeconds; i++) {
try {
session = new Cluster.Builder()
.addContactPoints("localhost")
.withPort(9042)
.withProtocolVersion(ProtocolVersion.V3)
.build().connect();
return;
} catch (NoHostAvailableException t) {
lastException = t;
}
Thread.sleep(1000);
}
if (lastException != null) {
throw lastException;
}
}
}

Expand Down

0 comments on commit ddccbb0

Please sign in to comment.