Search in sources :

Example 11 with ActorSystem

use of akka.actor.ActorSystem in project webofneeds by researchstudio-sat.

the class SolrTest method main.

public static void main(String[] args) throws IOException, InterruptedException {
    // init basic Akka
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(MatcherSolrAppConfiguration.class);
    ActorSystem system = ctx.getBean(ActorSystem.class);
    ActorRef solrMatcherActor = system.actorOf(SpringExtension.SpringExtProvider.get(system).props(SolrMatcherActor.class), "SolrMatcherActor");
    NeedEvent ne1 = createNeedEvent("/needmodel/need1.trig");
    NeedEvent ne2 = createNeedEvent("/needmodel/need2.trig");
    solrMatcherActor.tell(ne1, null);
    Thread.sleep(5000);
    solrMatcherActor.tell(ne2, null);
}
Also used : ActorSystem(akka.actor.ActorSystem) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) SolrMatcherActor(won.matcher.solr.actor.SolrMatcherActor) ActorRef(akka.actor.ActorRef) NeedEvent(won.matcher.service.common.event.NeedEvent)

Example 12 with ActorSystem

use of akka.actor.ActorSystem in project chuidiang-ejemplos by chuidiang.

the class Server1Main method main.

public static void main(String[] args) throws InterruptedException {
    // Override the configuration of the port
    // when specified as program argument
    System.setProperty("akka.remote.netty.tcp.port", "5557");
    // Create an Akka system
    ActorSystem system = ActorSystem.create("ClusterSystem");
    // Create an actor that handles cluster domain events
    ActorRef subscriber = system.actorOf(Props.create(Subscriber.class), "subscriptor");
}
Also used : ActorSystem(akka.actor.ActorSystem) ActorRef(akka.actor.ActorRef)

Example 13 with ActorSystem

use of akka.actor.ActorSystem in project controller by opendaylight.

the class DataChangeListenerRegistrationProxyTest method testFailedRegistration.

@Test
public void testFailedRegistration() {
    new TestKit(getSystem()) {

        {
            ActorSystem mockActorSystem = mock(ActorSystem.class);
            ActorRef mockActor = getSystem().actorOf(Props.create(DoNothingActor.class), "testFailedRegistration");
            doReturn(mockActor).when(mockActorSystem).actorOf(any(Props.class));
            ExecutionContextExecutor executor = ExecutionContexts.fromExecutor(MoreExecutors.directExecutor());
            ActorContext actorContext = mock(ActorContext.class);
            doReturn(executor).when(actorContext).getClientDispatcher();
            String shardName = "shard-1";
            final DataChangeListenerRegistrationProxy proxy = new DataChangeListenerRegistrationProxy(shardName, actorContext, mockListener);
            doReturn(mockActorSystem).when(actorContext).getActorSystem();
            doReturn(duration("5 seconds")).when(actorContext).getOperationDuration();
            doReturn(Futures.successful(getRef())).when(actorContext).findLocalShardAsync(eq(shardName));
            doReturn(Futures.failed(new RuntimeException("mock"))).when(actorContext).executeOperationAsync(any(ActorRef.class), any(Object.class), any(Timeout.class));
            doReturn(mock(DatastoreContext.class)).when(actorContext).getDatastoreContext();
            proxy.init(YangInstanceIdentifier.of(TestModel.TEST_QNAME), AsyncDataBroker.DataChangeScope.ONE);
            Assert.assertEquals("getListenerRegistrationActor", null, proxy.getListenerRegistrationActor());
            proxy.close();
        }
    };
}
Also used : ActorSystem(akka.actor.ActorSystem) ActorRef(akka.actor.ActorRef) Timeout(akka.util.Timeout) TestKit(akka.testkit.javadsl.TestKit) Props(akka.actor.Props) ActorContext(org.opendaylight.controller.cluster.datastore.utils.ActorContext) DoNothingActor(org.opendaylight.controller.cluster.raft.utils.DoNothingActor) ExecutionContextExecutor(scala.concurrent.ExecutionContextExecutor) Test(org.junit.Test)

Example 14 with ActorSystem

use of akka.actor.ActorSystem in project controller by opendaylight.

the class DataTreeChangeListenerProxyTest method testFailedRegistration.

@Test
public void testFailedRegistration() {
    new TestKit(getSystem()) {

        {
            ActorSystem mockActorSystem = mock(ActorSystem.class);
            ActorRef mockActor = getSystem().actorOf(Props.create(DoNothingActor.class), "testFailedRegistration");
            doReturn(mockActor).when(mockActorSystem).actorOf(any(Props.class));
            ExecutionContextExecutor executor = ExecutionContexts.fromExecutor(MoreExecutors.directExecutor());
            ActorContext actorContext = mock(ActorContext.class);
            final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
            doReturn(executor).when(actorContext).getClientDispatcher();
            doReturn(DatastoreContext.newBuilder().build()).when(actorContext).getDatastoreContext();
            doReturn(mockActorSystem).when(actorContext).getActorSystem();
            String shardName = "shard-1";
            final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(actorContext, mockListener, path);
            doReturn(duration("5 seconds")).when(actorContext).getOperationDuration();
            doReturn(Futures.successful(getRef())).when(actorContext).findLocalShardAsync(eq(shardName));
            doReturn(Futures.failed(new RuntimeException("mock"))).when(actorContext).executeOperationAsync(any(ActorRef.class), any(Object.class), any(Timeout.class));
            doReturn(mock(DatastoreContext.class)).when(actorContext).getDatastoreContext();
            proxy.init("shard-1");
            Assert.assertEquals("getListenerRegistrationActor", null, proxy.getListenerRegistrationActor());
            proxy.close();
        }
    };
}
Also used : ActorSystem(akka.actor.ActorSystem) ActorRef(akka.actor.ActorRef) Timeout(akka.util.Timeout) TestKit(akka.testkit.javadsl.TestKit) Props(akka.actor.Props) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) ActorContext(org.opendaylight.controller.cluster.datastore.utils.ActorContext) DoNothingActor(org.opendaylight.controller.cluster.raft.utils.DoNothingActor) DOMDataTreeChangeListener(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener) ClusteredDOMDataTreeChangeListener(org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener) ExecutionContextExecutor(scala.concurrent.ExecutionContextExecutor) Test(org.junit.Test)

Example 15 with ActorSystem

use of akka.actor.ActorSystem in project controller by opendaylight.

the class AbstractTest method newActorSystem.

protected ActorSystem newActorSystem(final String name, final String config) {
    ActorSystem system = ActorSystem.create(name, ConfigFactory.load().getConfig(config));
    actorSystems.add(system);
    return system;
}
Also used : ActorSystem(akka.actor.ActorSystem)

Aggregations

ActorSystem (akka.actor.ActorSystem)91 ActorRef (akka.actor.ActorRef)54 Test (org.junit.Test)51 Configuration (org.apache.flink.configuration.Configuration)27 FiniteDuration (scala.concurrent.duration.FiniteDuration)12 File (java.io.File)11 ActorGateway (org.apache.flink.runtime.instance.ActorGateway)11 LeaderRetrievalService (org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService)11 Props (akka.actor.Props)10 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)10 TestActorRef (akka.testkit.TestActorRef)8 IOException (java.io.IOException)8 AkkaActorGateway (org.apache.flink.runtime.instance.AkkaActorGateway)8 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)8 Deadline (scala.concurrent.duration.Deadline)8 AddressFromURIString (akka.actor.AddressFromURIString)7 ActorMaterializer (akka.stream.ActorMaterializer)7 Materializer (akka.stream.Materializer)7 Sink (akka.stream.javadsl.Sink)7 Source (akka.stream.javadsl.Source)7