use of com.tangosol.net.SessionConfiguration in project coherence-spring by coherence-community.
the class CoherencePropertiesTests method testCoherenceConfiguration.
@Test
void testCoherenceConfiguration() {
final List<ServerSessionConfigurationBean> serverSessions = this.coherenceProperties.getSessions().getServer();
assertThat(serverSessions.get(0).getConfiguration()).isNotNull();
assertThat(serverSessions.get(1).getConfiguration()).isNotNull();
assertThat(serverSessions.get(2).getConfiguration()).isNotNull();
final SessionConfiguration sessionConfiguration1 = serverSessions.get(0).getConfiguration().get();
final SessionConfiguration sessionConfiguration2 = serverSessions.get(1).getConfiguration().get();
final SessionConfiguration sessionConfiguration3 = serverSessions.get(2).getConfiguration().get();
assertThat(sessionConfiguration1.getName()).isEqualTo(Coherence.DEFAULT_NAME);
validateConfigUri("coherence-cache-config.xml", sessionConfiguration1);
assertThat(sessionConfiguration1.getScopeName()).isEqualTo("fooscope");
assertThat(sessionConfiguration1.getPriority()).isEqualTo(1);
assertThat(sessionConfiguration2.getName()).isEqualTo("test");
validateConfigUri("test-coherence-config.xml", sessionConfiguration2);
assertThat(sessionConfiguration2.getScopeName()).isEqualTo("barscope");
assertThat(sessionConfiguration2.getPriority()).isEqualTo(2);
assertThat(sessionConfiguration3.getName()).isEqualTo(Coherence.DEFAULT_NAME);
validateConfigUri("test-coherence-config.xml", sessionConfiguration3);
assertThat(sessionConfiguration3.getScopeName()).isEqualTo("myscope");
assertThat(sessionConfiguration3.getPriority()).isEqualTo(SessionConfiguration.DEFAULT_PRIORITY);
}
use of com.tangosol.net.SessionConfiguration in project micronaut-coherence by micronaut-projects.
the class GrpcSessionConfigurationBeanTest method shouldConfigureSessions.
@Test
void shouldConfigureSessions() {
Map<String, SessionConfiguration> beans = ctx.getBeansOfType(GrpcSessionConfigurationBean.class).stream().map(SessionConfigurationProvider::getConfiguration).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toMap(SessionConfiguration::getName, cfg -> cfg));
Optional<Channel> optional = ctx.findBean(Channel.class, Qualifiers.byName("default"));
assertThat(optional.isPresent(), is(true));
assertThat(beans.size(), is(2));
GrpcSessionConfiguration beanBar = (GrpcSessionConfiguration) beans.get("bar");
assertThat(beanBar, is(notNullValue()));
assertThat(beanBar.getName(), is("bar"));
assertThat(beanBar.getScopeName(), is(Coherence.DEFAULT_SCOPE));
assertThat(beanBar.getSerializer().orElseThrow(AssertionFailedError::new), notNullValue());
assertThat(beanBar.getFormat().orElseThrow(AssertionFailedError::new), is("java"));
assertThat(beanBar.enableTracing(), is(true));
GrpcSessionConfiguration beanBaz = (GrpcSessionConfiguration) beans.get("baz");
assertThat(beanBaz, is(notNullValue()));
assertThat(beanBaz.getName(), is("baz"));
assertThat(beanBaz.getScopeName(), is("scoped"));
assertThat(beanBaz.getSerializer().isPresent(), is(false));
assertThat(beanBaz.getFormat().orElseThrow(AssertionFailedError::new), is("binary"));
assertThat(beanBaz.enableTracing(), is(false));
}
use of com.tangosol.net.SessionConfiguration 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();
}
use of com.tangosol.net.SessionConfiguration 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();
}
use of com.tangosol.net.SessionConfiguration 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;
}
Aggregations