Search in sources :

Example 1 with JacksonModule

use of com.instaclustr.jackson.JacksonModule in project esop by instaclustr.

the class ManifestComponentsTest method setup.

@BeforeMethod
public void setup() throws Exception {
    final List<Module> modules = new ArrayList<Module>() {

        {
            add(new JacksonModule());
        }
    };
    final Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);
}
Also used : Injector(com.google.inject.Injector) ArrayList(java.util.ArrayList) Module(com.google.inject.Module) JacksonModule(com.instaclustr.jackson.JacksonModule) JacksonModule(com.instaclustr.jackson.JacksonModule) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with JacksonModule

use of com.instaclustr.jackson.JacksonModule in project esop by instaclustr.

the class ManifestTest method setup.

@BeforeMethod
public void setup() throws Exception {
    final List<Module> modules = new ArrayList<Module>() {

        {
            add(new KubernetesApiModule());
            add(new ExecutorsModule());
            add(new CassandraModule());
            add(new JacksonModule());
        }
    };
    final Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);
    operationsService = new OperationsService(executorServiceSupplier.get());
    cassandra = getCassandra();
    cassandra.start();
    waitForCql();
    session = CqlSession.builder().build();
}
Also used : CassandraModule(com.instaclustr.cassandra.CassandraModule) ExecutorsModule(com.instaclustr.threading.ExecutorsModule) Injector(com.google.inject.Injector) KubernetesApiModule(com.instaclustr.kubernetes.KubernetesApiModule) ArrayList(java.util.ArrayList) Module(com.google.inject.Module) KubernetesApiModule(com.instaclustr.kubernetes.KubernetesApiModule) CassandraModule(com.instaclustr.cassandra.CassandraModule) ExecutorsModule(com.instaclustr.threading.ExecutorsModule) JacksonModule(com.instaclustr.jackson.JacksonModule) JacksonModule(com.instaclustr.jackson.JacksonModule) OperationsService(com.instaclustr.operations.OperationsService) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with JacksonModule

use of com.instaclustr.jackson.JacksonModule in project esop by instaclustr.

the class Esop method init.

static void init(final Runnable command, final CassandraJMXSpec jmxSpec, final HashSpec hashSpec, final OperationRequest operationRequest, final Logger logger, final List<Module> appSpecificModules) {
    final List<Module> modules = new ArrayList<>();
    if (jmxSpec != null) {
        modules.add(new CassandraModule(new CassandraJMXConnectionInfo(jmxSpec)));
    } else {
        modules.add(new AbstractModule() {

            @Override
            protected void configure() {
                bind(StorageServiceMBean.class).toProvider(() -> null);
                bind(Cassandra4StorageServiceMBean.class).toProvider(() -> null);
            }
        });
    }
    modules.add(new JacksonModule());
    modules.add(new OperationsModule());
    modules.add(new StorageModules());
    modules.add(new ExecutorsModule());
    modules.add(new UploadingModule());
    modules.add(new DownloadingModule());
    modules.add(new HashModule(hashSpec));
    modules.addAll(appSpecificModules);
    final Injector injector = Guice.createInjector(// production binds singletons as eager by default
    Stage.PRODUCTION, modules);
    GuiceInjectorHolder.INSTANCE.setInjector(injector);
    injector.injectMembers(command);
    final Validator validator = Validation.byDefaultProvider().configure().constraintValidatorFactory(new GuiceInjectingConstraintValidatorFactory()).buildValidatorFactory().getValidator();
    final Set<ConstraintViolation<OperationRequest>> violations = validator.validate(operationRequest);
    if (!violations.isEmpty()) {
        violations.forEach(violation -> logger.error(violation.getMessage()));
        throw new ValidationException();
    }
}
Also used : UploadingModule(com.instaclustr.esop.impl.backup.BackupModules.UploadingModule) ValidationException(javax.validation.ValidationException) ArrayList(java.util.ArrayList) JacksonModule(com.instaclustr.jackson.JacksonModule) OperationsModule(com.instaclustr.operations.OperationsModule) AbstractModule(com.google.inject.AbstractModule) HashModule(com.instaclustr.esop.impl.hash.HashModule) CassandraModule(com.instaclustr.cassandra.CassandraModule) CassandraJMXConnectionInfo(jmx.org.apache.cassandra.CassandraJMXConnectionInfo) DownloadingModule(com.instaclustr.esop.impl.restore.RestoreModules.DownloadingModule) StorageModules(com.instaclustr.esop.guice.StorageModules) ExecutorsModule(com.instaclustr.threading.ExecutorsModule) Injector(com.google.inject.Injector) ConstraintViolation(javax.validation.ConstraintViolation) OperationsModule(com.instaclustr.operations.OperationsModule) Module(com.google.inject.Module) HashModule(com.instaclustr.esop.impl.hash.HashModule) UploadingModule(com.instaclustr.esop.impl.backup.BackupModules.UploadingModule) CassandraModule(com.instaclustr.cassandra.CassandraModule) ExecutorsModule(com.instaclustr.threading.ExecutorsModule) DownloadingModule(com.instaclustr.esop.impl.restore.RestoreModules.DownloadingModule) JacksonModule(com.instaclustr.jackson.JacksonModule) AbstractModule(com.google.inject.AbstractModule) GuiceInjectingConstraintValidatorFactory(com.instaclustr.validation.GuiceInjectingConstraintValidatorFactory) Validator(javax.validation.Validator)

Aggregations

Injector (com.google.inject.Injector)3 Module (com.google.inject.Module)3 JacksonModule (com.instaclustr.jackson.JacksonModule)3 ArrayList (java.util.ArrayList)3 CassandraModule (com.instaclustr.cassandra.CassandraModule)2 ExecutorsModule (com.instaclustr.threading.ExecutorsModule)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 AbstractModule (com.google.inject.AbstractModule)1 StorageModules (com.instaclustr.esop.guice.StorageModules)1 UploadingModule (com.instaclustr.esop.impl.backup.BackupModules.UploadingModule)1 HashModule (com.instaclustr.esop.impl.hash.HashModule)1 DownloadingModule (com.instaclustr.esop.impl.restore.RestoreModules.DownloadingModule)1 KubernetesApiModule (com.instaclustr.kubernetes.KubernetesApiModule)1 OperationsModule (com.instaclustr.operations.OperationsModule)1 OperationsService (com.instaclustr.operations.OperationsService)1 GuiceInjectingConstraintValidatorFactory (com.instaclustr.validation.GuiceInjectingConstraintValidatorFactory)1 ConstraintViolation (javax.validation.ConstraintViolation)1 ValidationException (javax.validation.ValidationException)1 Validator (javax.validation.Validator)1 CassandraJMXConnectionInfo (jmx.org.apache.cassandra.CassandraJMXConnectionInfo)1