Search in sources :

Example 1 with IMessagingSkeleton

use of io.joynr.messaging.IMessagingSkeleton in project joynr by bmwcarit.

the class CcMessageRouterTest method setUp.

@Before
public void setUp() throws Exception {
    when(middlewareMessagingStubFactoryMock.create(any(ChannelAddress.class))).thenReturn(messagingStubMock);
    AbstractModule mockModule = new AbstractModule() {

        private Long msgRetryIntervalMs = 10L;

        // message runnables + cleanup thread
        private int numberOfThreads = maximumParallelSends + 1;

        private long routingTableGracePeriodMs = 30000;

        private long routingTableCleanupIntervalMs = 60000;

        @Override
        protected void configure() {
            bind(MessageRouter.class).to(CcMessageRouter.class);
            bind(RoutingTable.class).toInstance(routingTable);
            bind(AddressManager.class).toInstance(addressManager);
            bind(MulticastReceiverRegistry.class).toInstance(multicastReceiverRegistry);
            bind(ShutdownNotifier.class).toInstance(shutdownNotifier);
            bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_SEND_MSG_RETRY_INTERVAL_MS)).toInstance(msgRetryIntervalMs);
            bind(Integer.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_MESSAGING_MAXIMUM_PARALLEL_SENDS)).toInstance(maximumParallelSends);
            bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_ROUTING_TABLE_GRACE_PERIOD_MS)).toInstance(routingTableGracePeriodMs);
            bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_ROUTING_TABLE_CLEANUP_INTERVAL_MS)).toInstance(routingTableCleanupIntervalMs);
            bindConstant().annotatedWith(Names.named(ClusterControllerRuntimeModule.PROPERTY_ACCESSCONTROL_ENABLE)).to(false);
            bind(AccessController.class).toInstance(Mockito.mock(AccessController.class));
            bind(StatusReceiver.class).toInstance(statusReceiver);
            MapBinder<Class<? extends Address>, AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>> messagingStubFactory;
            messagingStubFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
            }, new TypeLiteral<AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>>() {
            }, Names.named(MessagingStubFactory.MIDDLEWARE_MESSAGING_STUB_FACTORIES));
            messagingStubFactory.addBinding(ChannelAddress.class).toInstance(middlewareMessagingStubFactoryMock);
            MapBinder<Class<? extends Address>, IMessagingSkeleton> messagingSkeletonFactory;
            messagingSkeletonFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
            }, new TypeLiteral<IMessagingSkeleton>() {
            }, Names.named(MessagingSkeletonFactory.MIDDLEWARE_MESSAGING_SKELETONS));
            messagingSkeletonFactory.addBinding(ChannelAddress.class).toInstance(messagingSkeletonMock);
            Multibinder.newSetBinder(binder(), new TypeLiteral<MulticastAddressCalculator>() {
            });
        }

        @Provides
        @Named(MessageRouter.SCHEDULEDTHREADPOOL)
        ScheduledExecutorService provideMessageSchedulerThreadPoolExecutor() {
            ThreadFactory schedulerNamedThreadFactory = new ThreadFactoryBuilder().setNameFormat("joynr.MessageScheduler-scheduler-%d").build();
            ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(numberOfThreads, schedulerNamedThreadFactory);
            scheduler.setKeepAliveTime(100, TimeUnit.SECONDS);
            scheduler.allowCoreThreadTimeOut(true);
            return scheduler;
        }
    };
    testModule = Modules.override(mockModule).with(new TestGlobalAddressModule());
    Injector injector = Guice.createInjector(testModule);
    messageRouter = injector.getInstance(MessageRouter.class);
    ObjectMapper objectMapper = new ObjectMapper();
    messageFactory = new MutableMessageFactory(objectMapper, new HashSet<JoynrMessageProcessor>());
    // toParticipantId is globally visible
    final boolean isGloballyVisible = true;
    final long expiryDateMs = Long.MAX_VALUE;
    final boolean isSticky = true;
    final boolean allowUpdate = false;
    routingTable.put(toParticipantId, channelAddress, isGloballyVisible, expiryDateMs, isSticky, allowUpdate);
    Request request = new Request("noMethod", new Object[] {}, new String[] {}, "requestReplyId");
    joynrMessage = messageFactory.createRequest(fromParticipantId, toParticipantId, request, new MessagingQos());
    joynrMessage.setLocalMessage(true);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) TestGlobalAddressModule(io.joynr.messaging.routing.TestGlobalAddressModule) IMessagingSkeleton(io.joynr.messaging.IMessagingSkeleton) Address(joynr.system.RoutingTypes.Address) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) CcMessageRouter(io.joynr.messaging.routing.CcMessageRouter) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) StatusReceiver(io.joynr.statusmetrics.StatusReceiver) MessagingQos(io.joynr.messaging.MessagingQos) TypeLiteral(com.google.inject.TypeLiteral) Injector(com.google.inject.Injector) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) ShutdownNotifier(io.joynr.runtime.ShutdownNotifier) Request(joynr.Request) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) AbstractModule(com.google.inject.AbstractModule) AbstractMiddlewareMessagingStubFactory(io.joynr.messaging.AbstractMiddlewareMessagingStubFactory) AccessController(io.joynr.accesscontrol.AccessController) MutableMessageFactory(io.joynr.dispatching.MutableMessageFactory) IMessagingStub(io.joynr.messaging.IMessagingStub) Before(org.junit.Before)

Example 2 with IMessagingSkeleton

use of io.joynr.messaging.IMessagingSkeleton in project joynr by bmwcarit.

the class JeeJoynrIntegrationModule method configure.

@Override
protected void configure() {
    bind(ScheduledExecutorService.class).annotatedWith(Names.named(MessageRouter.SCHEDULEDTHREADPOOL)).toInstance(scheduledExecutorService);
    bind(ScheduledExecutorService.class).annotatedWith(Names.named(JoynrInjectionConstants.JOYNR_SCHEDULER_CLEANUP)).toInstance(scheduledExecutorService);
    bind(ScheduledExecutorService.class).annotatedWith(Names.named(LocalCapabilitiesDirectory.JOYNR_SCHEDULER_CAPABILITIES_FRESHNESS)).toInstance(scheduledExecutorService);
    bind(ExecutorService.class).toInstance(scheduledExecutorService);
    MapBinder<Class<? extends Address>, IMessagingSkeleton> messagingSkeletonFactory;
    messagingSkeletonFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
    }, new TypeLiteral<IMessagingSkeleton>() {
    }, Names.named(MessagingSkeletonFactory.MIDDLEWARE_MESSAGING_SKELETONS));
    MapBinder<Class<? extends Address>, AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>> messagingStubFactory;
    messagingStubFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
    }, new TypeLiteral<AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>>() {
    }, Names.named(MessagingStubFactory.MIDDLEWARE_MESSAGING_STUB_FACTORIES));
    Multibinder.newSetBinder(binder(), JoynrMessageProcessor.class);
    install(new JeeHttpMessagingModule(messagingSkeletonFactory, messagingStubFactory));
    install(new HttpBridgeEndpointRegistryClientModule());
    install(new JeeMqttMessageSendingModule(messagingSkeletonFactory, messagingStubFactory));
}
Also used : AbstractMiddlewareMessagingStubFactory(io.joynr.messaging.AbstractMiddlewareMessagingStubFactory) JeeHttpMessagingModule(io.joynr.jeeintegration.messaging.JeeHttpMessagingModule) IMessagingSkeleton(io.joynr.messaging.IMessagingSkeleton) Address(joynr.system.RoutingTypes.Address) TypeLiteral(com.google.inject.TypeLiteral) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) JeeMqttMessageSendingModule(io.joynr.jeeintegration.messaging.JeeMqttMessageSendingModule) IMessagingStub(io.joynr.messaging.IMessagingStub) HttpBridgeEndpointRegistryClientModule(io.joynr.jeeintegration.httpbridge.HttpBridgeEndpointRegistryClientModule)

Example 3 with IMessagingSkeleton

use of io.joynr.messaging.IMessagingSkeleton in project joynr by bmwcarit.

the class AbstractMessageRouter method performSubscriptionOperation.

private void performSubscriptionOperation(String multicastId, String providerParticipantId, SubscriptionOperation operation) {
    Address providerAddress = routingTable.get(providerParticipantId);
    IMessagingSkeleton messagingSkeleton = messagingSkeletonFactory.getSkeleton(providerAddress);
    if (messagingSkeleton != null && messagingSkeleton instanceof IMessagingMulticastSubscriber) {
        operation.perform((IMessagingMulticastSubscriber) messagingSkeleton);
    } else {
        logger.trace("No messaging skeleton found for address {}, not performing multicast subscription.", providerAddress);
    }
}
Also used : IMessagingMulticastSubscriber(io.joynr.messaging.IMessagingMulticastSubscriber) IMessagingSkeleton(io.joynr.messaging.IMessagingSkeleton) Address(joynr.system.RoutingTypes.Address)

Aggregations

IMessagingSkeleton (io.joynr.messaging.IMessagingSkeleton)3 Address (joynr.system.RoutingTypes.Address)3 TypeLiteral (com.google.inject.TypeLiteral)2 AbstractMiddlewareMessagingStubFactory (io.joynr.messaging.AbstractMiddlewareMessagingStubFactory)2 IMessagingStub (io.joynr.messaging.IMessagingStub)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 AccessController (io.joynr.accesscontrol.AccessController)1 MutableMessageFactory (io.joynr.dispatching.MutableMessageFactory)1 HttpBridgeEndpointRegistryClientModule (io.joynr.jeeintegration.httpbridge.HttpBridgeEndpointRegistryClientModule)1 JeeHttpMessagingModule (io.joynr.jeeintegration.messaging.JeeHttpMessagingModule)1 JeeMqttMessageSendingModule (io.joynr.jeeintegration.messaging.JeeMqttMessageSendingModule)1 IMessagingMulticastSubscriber (io.joynr.messaging.IMessagingMulticastSubscriber)1 MessagingQos (io.joynr.messaging.MessagingQos)1 CcMessageRouter (io.joynr.messaging.routing.CcMessageRouter)1 TestGlobalAddressModule (io.joynr.messaging.routing.TestGlobalAddressModule)1 ShutdownNotifier (io.joynr.runtime.ShutdownNotifier)1 StatusReceiver (io.joynr.statusmetrics.StatusReceiver)1