Skip to content

Commit

Permalink
align project with esop 3.0.1, sidecar-commons 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
smiklosovic committed Oct 1, 2024
1 parent 1db15a1 commit a4e717f
Show file tree
Hide file tree
Showing 40 changed files with 477 additions and 504 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
working_directory: ~/icarus

docker:
- image: cimg/openjdk:8.0
- image: cimg/openjdk:11.0.20

steps:

Expand All @@ -16,7 +16,7 @@ jobs:
- m2-{{ checksum "pom.xml" }}
- m2-

- run: (echo "${google_application_credentials}" > /tmp/gcp.json) && mvn -PsnapshotRepo,deb,rpm,cloudTests clean install -DoutputDirectory=/tmp/artifacts -Dcassandra.version=4.1.0
- run: (echo "${google_application_credentials}" > /tmp/gcp.json) && mvn -PsnapshotRepo,deb,rpm,noCloudTests clean install -DoutputDirectory=/tmp/artifacts -Dcassandra.version=4.1.0

- save_cache:
paths:
Expand All @@ -38,15 +38,15 @@ jobs:

publish-github-release:
docker:
- image: cimg/go:1.17
- image: cimg/go:1.21.1
steps:
- attach_workspace:
at: ./artifacts
- run:
name: "Publish Release on GitHub"
command: |
set -xue
go get github.com/tcnksm/ghr
go install github.com/tcnksm/ghr@latest
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./artifacts/
workflows:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ target/
dependency-reduced-pom.xml
*.log
/run-cloud-tests.sh
topology/
src/main/resources/git.properties
33 changes: 20 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,29 @@

<groupId>com.instaclustr</groupId>
<artifactId>icarus</artifactId>
<version>2.0.4</version>
<version>3.0.0-SNAPSHOT</version>

<name>instaclustr-icarus</name>
<description>Sidecar for Apache Cassandra</description>
<url>https://github.com/instaclustr/instaclustr-icarus</url>

<properties>
<instaclustr.sidecar.common.version>1.3.18</instaclustr.sidecar.common.version>
<instaclustr.esop.version>2.0.4</instaclustr.esop.version>
<instaclustr.sidecar.common.version>2.0.0</instaclustr.sidecar.common.version>
<instaclustr.esop.version>3.0.1</instaclustr.esop.version>

<testng.version>6.14.3</testng.version>
<testng.version>7.5</testng.version>
<mockito.version>2.23.4</mockito.version>
<awaitility.version>3.1.6</awaitility.version>
<cassandra.driver.version>4.11.1</cassandra.driver.version>
<version.embedded.cassandra>4.0.1</version.embedded.cassandra>

<maven.compiler.plugin.version>3.11.0</maven.compiler.plugin.version>
<maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
<nexus.staging.maven.plugin.version>1.6.8</nexus.staging.maven.plugin.version>
<maven.shade.plugin.version>3.1.1</maven.shade.plugin.version>
<git.command.plugin.version>2.2.4</git.command.plugin.version>
<git.command.plugin.version>4.0.4</git.command.plugin.version>
<maven.jar.plugin.version>3.1.1</maven.jar.plugin.version>
<maven.surefire.plugin.version>3.0.0-M4</maven.surefire.plugin.version>
<maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version>
<maven.javadoc.plugin.version>3.1.1</maven.javadoc.plugin.version>
<maven.source.plugin.version>3.1.0</maven.source.plugin.version>

Expand All @@ -39,11 +40,6 @@

<outputDirectory>${project.build.directory}</outputDirectory>

<java.version>1.8</java.version>

<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -502,7 +498,9 @@
</execution>
</executions>
<configuration>
<dotGitDirectory>${project.basedir}/../.git</dotGitDirectory>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.basedir}/src/main/resources/git.properties</generateGitPropertiesFilename>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
</configuration>
</plugin>
<plugin>
Expand All @@ -518,7 +516,7 @@
</execution>
</executions>
<configuration>
<source>${java.version}</source>
<source>11</source>
</configuration>
</plugin>
<plugin>
Expand All @@ -534,6 +532,15 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<release>8</release>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
20 changes: 10 additions & 10 deletions src/main/java/com/instaclustr/icarus/Icarus.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
import static com.google.inject.Stage.PRODUCTION;
import static com.instaclustr.operations.OperationBindings.installOperationBindings;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.Callable;

import com.google.inject.AbstractModule;
Expand Down Expand Up @@ -34,7 +39,6 @@
import com.instaclustr.icarus.operations.flush.FlushModule;
import com.instaclustr.icarus.operations.rebuild.RebuildModule;
import com.instaclustr.icarus.operations.refresh.RefreshModule;
import com.instaclustr.icarus.operations.restart.RestartModule;
import com.instaclustr.icarus.operations.scrub.ScrubModule;
import com.instaclustr.icarus.operations.icarus.IcarusModule;
import com.instaclustr.icarus.operations.upgradesstables.UpgradeSSTablesModule;
Expand Down Expand Up @@ -97,20 +101,12 @@ public static void main(final String[] args, boolean exit) {

@Override
public Void call() throws Exception {

logCommandVersionInformation(commandSpec);

// production binds singletons as eager by default
final Injector injector = createInjector(PRODUCTION, getModules(icarusSpec, jmxSpec, hashSpec, enableTruncateOperation));

return injector.getInstance(Application.class).call();
}

@Override
public String getImplementationTitle() {
return "instaclustr-icarus";
}

public List<AbstractModule> getModules(final SidecarSpec icarusSpec,
final CassandraJMXSpec jmxSpec,
final HashSpec hashSpec,
Expand Down Expand Up @@ -187,11 +183,15 @@ public static List<AbstractModule> operationModules() {
add(new RebuildModule());
add(new ScrubModule());
add(new DrainModule());
add(new RestartModule());
add(new IcarusModule());
add(new RefreshModule());
add(new FlushModule());
add(new ImportModule());
}};
}

@Override
public String title() {
return "instaclustr-icarus";
}
}
51 changes: 46 additions & 5 deletions src/main/java/com/instaclustr/icarus/IcarusAggregationCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Spec;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Optional;
import java.util.Properties;

@Command(
mixinStandardHelpOptions = true,
subcommands = {Esop.class, Icarus.class},
versionProvider = IcarusAggregationCommand.class,
versionProvider = IcarusAggregationCommand.IcarusVersionParser.class,
usageHelpWidth = 128
)
public class IcarusAggregationCommand extends CLIApplication implements Runnable {
Expand All @@ -31,12 +37,47 @@ public static void main(String[] args, boolean exit) {
}

@Override
public String getImplementationTitle() {
return "icarus-aggregator";
public void run() {
throw new CommandLine.ParameterException(spec.commandLine(), "Missing required sub-command.");
}

@Override
public void run() {
throw new CommandLine.ParameterException(spec.commandLine(), "Missing required sub-command.");
public String title() {
return "icarus-aggregator";
}

public static class IcarusVersionParser implements CommandLine.IVersionProvider {
public IcarusVersionParser() {
}

public static String[] parse(String title) throws IOException {
Enumeration<URL> resources = CommandLine.class.getClassLoader().getResources("git.properties");
Optional<String> implementationVersion = Optional.empty();
Optional<String> buildTime = Optional.empty();
Optional<String> gitCommit = Optional.empty();

while(resources.hasMoreElements()) {
URL url = (URL)resources.nextElement();
Properties properties = new Properties();
properties.load(url.openStream());

if (properties.getProperty("git.build.time") != null) {
implementationVersion = Optional.ofNullable(properties.getProperty("git.build.version"));
buildTime = Optional.ofNullable(properties.getProperty("git.build.time"));
gitCommit = Optional.ofNullable(properties.getProperty("git.commit.id"));
}
}

return new String[]{
String.format("%s %s", title, implementationVersion.orElse("development build")),
String.format("Build time: %s", buildTime.orElse("unknown")),
String.format("Git commit: %s", gitCommit.orElse("unknown"))
};
}

@Override
public String[] getVersion() throws Exception {
return IcarusVersionParser.parse("instaclustr-icarus");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ public void coordinate(final Operation<RestoreOperationRequest> operation) throw
int normalRequests = 0;

for (final UUID uuid : restoreUUIDs) {
final Optional<Operation> operationOptional = operationsService.operation(uuid);
final Optional<Operation<?>> operationOptional = operationsService.operation(uuid);

if (!operationOptional.isPresent()) {
throw new IllegalStateException(format("received empty optional for uuid %s", uuid.toString()));
}

final Operation op = operationOptional.get();
final Operation<?> op = operationOptional.get();

if (!(op.request instanceof RestoreOperationRequest)) {
throw new IllegalStateException(format("Received request is not of type %s", RestoreOperationRequest.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.instaclustr.icarus.operations.cleanup;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonCreator;
Expand Down Expand Up @@ -55,15 +53,13 @@
*/
public class CleanupOperationRequest extends OperationRequest {

@NotEmpty
public final String keyspace;

public final Set<String> tables;

@Min(0)
public final int jobs;

public CleanupOperationRequest(@NotEmpty final String keyspace, final Set<String> tables, @Min(0) final int jobs) {
public CleanupOperationRequest(final String keyspace, final Set<String> tables, final int jobs) {
this("cleanup", keyspace, tables, jobs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public DecommissionOperation(final CassandraJMXService cassandraJMXService,
this.cassandraVersionProvider = cassandraVersionProvider;
}

// this constructor is not meant to be instantiated manually
// and it fulfills the purpose of deserialisation from JSON string to an Operation object, currently just for testing purposes
// this constructor is not meant to be instantiated manually,
// and it fulfills the purpose of deserialization from JSON string to an Operation object, currently just for testing purposes
@JsonCreator
private DecommissionOperation(@JsonProperty("type") final String type,
@JsonProperty("id") final UUID id,
Expand All @@ -51,11 +51,11 @@ protected void run0() throws Exception {
assert cassandraJMXService != null;
assert cassandraVersionProvider != null;

if (cassandraVersionProvider.get().getMajor() == 4) {
if (cassandraVersionProvider.get().getMajor() >= 4) {
cassandraJMXService.doWithCassandra4StorageServiceMBean(new FunctionWithEx<Cassandra4StorageServiceMBean, Void>() {
@Override
public Void apply(final Cassandra4StorageServiceMBean object) throws Exception {
object.decommission(request.force == null ? true : request.force);
object.decommission(request.force == null || request.force);
return null;
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.instaclustr.icarus.operations.flush;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonCreator;
Expand All @@ -11,12 +9,11 @@

public class FlushOperationRequest extends OperationRequest {

@NotEmpty
public String keyspace;

public Set<String> tables;

public FlushOperationRequest(@NotNull final String keyspace, final Set<String> tables) {
public FlushOperationRequest(final String keyspace, final Set<String> tables) {
this("flush", keyspace, tables);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public StopIcarusOperation(OperationsService operationsService,
@Override
protected void run0() throws Exception {
Awaitility.await().pollInterval(10, SECONDS).atMost(5, MINUTES).until(() -> {
final List<Operation> otherOperations = operationsService.getOperations(op -> op.request.getClass() != StopIcarusOperationRequest.class);
final List<Operation<?>> otherOperations = operationsService.getOperations(op -> op.request.getClass() != StopIcarusOperationRequest.class);

if (otherOperations.size() != 0) {
logger.info("Waiting for operations to stop: " + otherOperations.stream().map(op -> op.id).collect(toList()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.instaclustr.icarus.operations.rebuild;

import javax.validation.constraints.NotEmpty;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonCreator;
Expand Down Expand Up @@ -63,7 +62,6 @@
* pick any DC
* }</pre>
*/
@ValidRebuildOperationRequest
public class RebuildOperationRequest extends OperationRequest {

public final String sourceDC;
Expand All @@ -86,10 +84,8 @@ public RebuildOperationRequest(@JsonProperty("type") final String type,

public static final class TokenRange {

@NotEmpty
public final String start;

@NotEmpty
public final String end;

@JsonCreator
Expand Down
Loading

0 comments on commit a4e717f

Please sign in to comment.