use of org.apache.openejb.util.Duration in project tomee by apache.
the class MultipointDiscoveryAgent method init.
@Override
public void init(final Properties props) {
final Options options = new Options(props);
options.setLogger(new OptionsLog(log));
host = props.getProperty("bind", host);
port = options.get("port", port);
initialServers = options.get("initialServers", initialServers);
heartRate = options.get("heart_rate", heartRate);
discoveryHost = options.get("discoveryHost", host);
name = name != null ? name : options.get("discoveryName", MultipointServer.randomColor());
reconnectDelay = options.get("reconnectDelay", new Duration("30 seconds"));
final Set<URI> uris = new LinkedHashSet<URI>();
// Connect the initial set of peer servers
final StringTokenizer st = new StringTokenizer(initialServers, ",");
while (st.hasMoreTokens()) {
final String string = st.nextToken().trim();
if (string.startsWith("conn://")) {
final URI uri = URI.create(string);
uris.add(uri);
} else {
final URI uri = URI.create("conn://" + string);
uris.add(uri);
}
}
roots = uris;
final Tracker.Builder builder = new Tracker.Builder();
builder.setHeartRate(heartRate);
builder.setGroup(props.getProperty("group", builder.getGroup()));
builder.setMaxMissedHeartbeats(options.get("max_missed_heartbeats", builder.getMaxMissedHeartbeats()));
builder.setMaxReconnectDelay(options.get("max_reconnect_delay", builder.getMaxReconnectDelay()));
builder.setReconnectDelay(options.get("reconnect_delay", builder.getReconnectDelay()));
builder.setExponentialBackoff(options.get("exponential_backoff", builder.getExponentialBackoff()));
builder.setMaxReconnectAttempts(options.get("max_reconnect_attempts", builder.getMaxReconnectAttempts()));
builder.setDebug(debug);
tracker = builder.build();
}
use of org.apache.openejb.util.Duration in project tomee by apache.
the class ActiveMQResourceAdapterTest method testSchedulerSupport.
public void testSchedulerSupport() throws Exception {
final ActiveMQResourceAdapter resourceAdapter = new ActiveMQResourceAdapter();
resourceAdapter.setServerUrl("vm://localhost?waitForStart=30000&async=false");
resourceAdapter.setStartupTimeout(new Duration(10, TimeUnit.SECONDS));
final String brokerAddress = NetworkUtil.getLocalAddress("broker:(tcp://", ")?useJmx=false&schedulerSupport=true");
resourceAdapter.setBrokerXmlConfig(brokerAddress);
resourceAdapter.start(null);
assertTrue(Boolean.class.cast(Reflections.get(ActiveMQFactory.getBrokers().iterator().next(), "schedulerSupport")));
resourceAdapter.stop();
resourceAdapter.setBrokerXmlConfig(NetworkUtil.getLocalAddress("broker:(tcp://", ")?useJmx=false&schedulerSupport=false"));
resourceAdapter.start(null);
assertFalse(Boolean.class.cast(Reflections.get(ActiveMQFactory.getBrokers().iterator().next(), "schedulerSupport")));
resourceAdapter.stop();
}
use of org.apache.openejb.util.Duration in project tomee by apache.
the class GeronimoConnectionManagerFactoryTest method eviction.
// ensure we don't have an exception TOMEE-1806
@Test
public void eviction() throws Exception {
final MyMcf mcf = new MyMcf();
final GeronimoConnectionManagerFactory factory = new GeronimoConnectionManagerFactory();
factory.setValidationInterval(new Duration("1 second"));
factory.setTransactionSupport("local");
factory.setMcf(mcf);
factory.setPooling(true);
factory.setPartitionStrategy("none");
factory.setTransactionManager(new TransactionManagerImpl());
factory.setPoolMinSize(1);
factory.setAllConnectionsEqual(true);
final GenericConnectionManager mgr = factory.create();
mgr.doStart();
try {
mgr.allocateConnection(mcf, new // just to use it
ConnectionRequestInfo() {
});
sleep(2500);
assertTrue(mcf.evicted.get());
assertTrue(mcf.destroyed.get());
} finally {
mgr.doStop();
}
}
use of org.apache.openejb.util.Duration in project tomee by apache.
the class AsynchronousPool method create.
public static AsynchronousPool create(final AppContext appContext) {
final Options options = appContext.getOptions();
final ExecutorBuilder builder = new ExecutorBuilder().prefix("AsynchronousPool").size(options.get("AsynchronousPool.Size", 5)).threadFactory(new DaemonThreadFactory("@Asynchronous", appContext.getId()));
return new AsynchronousPool(builder.build(options), options.get("AsynchronousPool.ShutdownWaitDuration", new Duration(1, TimeUnit.MINUTES)));
}
use of org.apache.openejb.util.Duration in project tomee by apache.
the class StatefulContainer method getAccessTimeout.
private Duration getAccessTimeout(final BeanContext beanContext, Method callMethod) {
callMethod = beanContext.getMatchingBeanMethod(callMethod);
Duration accessTimeout = beanContext.getAccessTimeout(callMethod);
if (accessTimeout == null) {
accessTimeout = beanContext.getAccessTimeout();
if (accessTimeout == null) {
accessTimeout = this.accessTimeout;
}
}
return accessTimeout;
}
Aggregations