Search in sources :

Example 11 with Duration

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();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Options(org.apache.openejb.loader.Options) StringTokenizer(java.util.StringTokenizer) OptionsLog(org.apache.openejb.util.OptionsLog) Duration(org.apache.openejb.util.Duration) URI(java.net.URI)

Example 12 with Duration

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();
}
Also used : Duration(org.apache.openejb.util.Duration)

Example 13 with Duration

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();
    }
}
Also used : GenericConnectionManager(org.apache.geronimo.connector.outbound.GenericConnectionManager) TransactionManagerImpl(org.apache.geronimo.transaction.manager.TransactionManagerImpl) Duration(org.apache.openejb.util.Duration) Test(org.junit.Test)

Example 14 with Duration

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)));
}
Also used : Options(org.apache.openejb.loader.Options) ExecutorBuilder(org.apache.openejb.util.ExecutorBuilder) DaemonThreadFactory(org.apache.openejb.util.DaemonThreadFactory) Duration(org.apache.openejb.util.Duration)

Example 15 with Duration

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;
}
Also used : Duration(org.apache.openejb.util.Duration)

Aggregations

Duration (org.apache.openejb.util.Duration)20 HashMap (java.util.HashMap)6 Map (java.util.Map)5 File (java.io.File)4 NamingException (javax.naming.NamingException)4 OpenEJBException (org.apache.openejb.OpenEJBException)4 Test (org.junit.Test)4 Method (java.lang.reflect.Method)3 Properties (java.util.Properties)3 InitialContext (javax.naming.InitialContext)3 BeanContext (org.apache.openejb.BeanContext)3 Calculator (org.apache.openejb.itest.failover.ejb.Calculator)3 StandaloneServer (org.apache.openejb.server.control.StandaloneServer)3 PrintStream (java.io.PrintStream)2 RemoteException (java.rmi.RemoteException)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ExecutorService (java.util.concurrent.ExecutorService)2 TimeoutException (java.util.concurrent.TimeoutException)2 ConcurrentAccessTimeoutException (javax.ejb.ConcurrentAccessTimeoutException)2