Search in sources :

Example 1 with CoherenceConfiguration

use of com.tangosol.net.CoherenceConfiguration in project coherence-spring by coherence-community.

the class CacheStoreDemoIT method setup.

@BeforeAll
static void setup() throws Exception {
    File outputDir = MavenProjectFileUtils.ensureTestOutputFolder(CacheStoreDemoIT.class, null);
    File dbDir = new File(outputDir, "hsqldb");
    // clean-up any previous database files from old tests
    MavenProjectFileUtils.recursiveDelete(dbDir);
    // re-create the db folder
    assertThat(dbDir.mkdirs(), is(true));
    assertThat(dbDir.exists(), is(true));
    assertThat(dbDir.isDirectory(), is(true));
    // Run db processes on the local machine
    LocalPlatform platform = LocalPlatform.get();
    testLogs.init(CacheStoreDemoIT.class, "logs");
    // Start the HSQLDB listening on port 9001
    hsqldb = platform.launch(JavaApplication.class, ClassName.of(Server.class), WorkingDirectory.at(dbDir), testLogs, ClassPath.ofClass(Server.class), Arguments.of("--database.0", "file:testdb", "--dbname.0", "testdb", "--port", 9001), IPv4Preferred.yes(), DisplayName.of("HSQLDB"));
    // Start the Coherence demo server
    server = platform.launch(CoherenceClusterMember.class, ClassName.of(CacheStoreDemo.class), testLogs, SystemProperty.of("spring.jmx.enabled", true), LocalHost.only(), IPv4Preferred.yes(), DisplayName.of("server"));
    // Wait for Spring to start
    Eventually.assertDeferred(() -> server.invoke(IsSpringUp.INSTANCE), is(true));
    // Ensure the Coherence Extend proxy has started
    Eventually.assertDeferred(() -> server.invoke(new IsServiceRunning("Proxy")), is(true));
    // Create the local Coherence Extend client
    CoherenceConfiguration config = CoherenceConfiguration.builder().withSession(SessionConfiguration.create("client-cache-config.xml")).build();
    Coherence coherence = Coherence.client(config);
    // wait at most 1 minute for the Coherence DefaultCacheServer to start
    // DefaultCacheServer is started automatically by the application but for the
    // tests to pass we need to ensure it has finished starting cache services.
    coherence.start().get(1, TimeUnit.MINUTES);
    // Create the Coherence Session using the client cache configuration that will connect over Extend.
    session = coherence.getSession();
}
Also used : CoherenceClusterMember(com.oracle.bedrock.runtime.coherence.CoherenceClusterMember) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) Coherence(com.tangosol.net.Coherence) IsServiceRunning(com.oracle.bedrock.runtime.coherence.callables.IsServiceRunning) File(java.io.File) CoherenceConfiguration(com.tangosol.net.CoherenceConfiguration) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with CoherenceConfiguration

use of com.tangosol.net.CoherenceConfiguration in project coherence-hibernate by coherence-community.

the class CoherenceRegionFactory method prepareCoherenceSessionIfNeeded.

private void prepareCoherenceSessionIfNeeded(CoherenceHibernateProperties coherenceHibernateProperties) {
    if (this.coherenceSession == null) {
        final SessionConfiguration.Builder sessionConfigurationBuilder = SessionConfiguration.builder();
        if (coherenceHibernateProperties.getSessionName() != null) {
            sessionConfigurationBuilder.named(coherenceHibernateProperties.getSessionName());
        }
        sessionConfigurationBuilder.withConfigUri(coherenceHibernateProperties.getCacheConfigFilePath());
        final SessionConfiguration sessionConfiguration = sessionConfigurationBuilder.build();
        // GrpcSessionConfiguration.Builder
        final CoherenceConfiguration coherenceConfiguration = CoherenceConfiguration.builder().withSession(sessionConfiguration).build();
        final SessionType sessionType = coherenceHibernateProperties.getSessionType();
        this.coherence = this.createCoherenceInstance(sessionType, coherenceConfiguration);
        try {
            coherence.start().get();
        } catch (InterruptedException | ExecutionException ex) {
            throw new IllegalStateException("Unable to start Coherence instance.", ex);
        }
        if (coherenceHibernateProperties.getSessionName() != null) {
            this.setCoherenceSession(coherence.getSession(coherenceHibernateProperties.getSessionName()));
        } else {
            this.setCoherenceSession(coherence.getSession());
        }
    }
    this.coherenceSession.activate();
}
Also used : SessionType(com.oracle.coherence.hibernate.cache.v53.configuration.session.SessionType) ExecutionException(java.util.concurrent.ExecutionException) CoherenceConfiguration(com.tangosol.net.CoherenceConfiguration) SessionConfiguration(com.tangosol.net.SessionConfiguration)

Example 3 with CoherenceConfiguration

use of com.tangosol.net.CoherenceConfiguration in project coherence-spring by coherence-community.

the class CoherenceServerJunitExtension method beforeAll.

@Override
public void beforeAll(ExtensionContext context) throws Exception {
    System.setProperty("coherence.log", "slf4j");
    if (logger.isInfoEnabled()) {
        logger.info("JunitExtension - Starting up Coherence...");
    }
    final SessionConfiguration.Builder sessionConfigurationBuilder = (SessionConfiguration.Builder) getFromTestClassloader(SessionConfiguration.class).getMethod("builder").invoke(null);
    final SessionConfiguration sessionConfiguration = sessionConfigurationBuilder.withConfigUri(this.configUri).build();
    final CoherenceConfiguration.Builder coherenceBuilder = (CoherenceConfiguration.Builder) getFromTestClassloader(CoherenceConfiguration.class).getMethod("builder").invoke(null);
    final CoherenceConfiguration cfg = coherenceBuilder.withSessions(sessionConfiguration).build();
    this.coherence = (Coherence) getFromTestClassloader(Coherence.class).getMethod("clusterMember", CoherenceConfiguration.class).invoke(null, cfg);
    this.coherence.start().join();
}
Also used : CoherenceConfiguration(com.tangosol.net.CoherenceConfiguration) SessionConfiguration(com.tangosol.net.SessionConfiguration)

Example 4 with CoherenceConfiguration

use of com.tangosol.net.CoherenceConfiguration in project coherence-hibernate by coherence-community.

the class CoherenceServerApplication method coherenceServer.

@Bean(destroyMethod = "close")
public Coherence coherenceServer() {
    final SessionConfiguration sessionConfiguration = SessionConfiguration.builder().withConfigUri("coherence-cache-config.xml").build();
    final CoherenceConfiguration cfg = CoherenceConfiguration.builder().withSessions(sessionConfiguration).build();
    final Coherence coherence = Coherence.clusterMember(cfg);
    coherence.start().join();
    return coherence;
}
Also used : Coherence(com.tangosol.net.Coherence) CoherenceConfiguration(com.tangosol.net.CoherenceConfiguration) SessionConfiguration(com.tangosol.net.SessionConfiguration) Bean(org.springframework.context.annotation.Bean)

Aggregations

CoherenceConfiguration (com.tangosol.net.CoherenceConfiguration)4 SessionConfiguration (com.tangosol.net.SessionConfiguration)3 Coherence (com.tangosol.net.Coherence)2 LocalPlatform (com.oracle.bedrock.runtime.LocalPlatform)1 CoherenceClusterMember (com.oracle.bedrock.runtime.coherence.CoherenceClusterMember)1 IsServiceRunning (com.oracle.bedrock.runtime.coherence.callables.IsServiceRunning)1 JavaApplication (com.oracle.bedrock.runtime.java.JavaApplication)1 SessionType (com.oracle.coherence.hibernate.cache.v53.configuration.session.SessionType)1 File (java.io.File)1 ExecutionException (java.util.concurrent.ExecutionException)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 Bean (org.springframework.context.annotation.Bean)1