Search in sources :

Example 11 with Serializer

use of org.onosproject.store.service.Serializer in project onos by opennetworkinglab.

the class MeterManagerTest method setup.

@Before
public void setup() {
    DeviceService deviceService = new TestDeviceService();
    DriverRegistryManager driverRegistry = new DriverRegistryManager();
    DriverManager driverService = new TestDriverManager(driverRegistry, deviceService, new NetworkConfigServiceAdapter());
    driverRegistry.addDriver(new DefaultDriver("foo", ImmutableList.of(), "", "", "", ImmutableMap.of(MeterProgrammable.class, TestMeterProgrammable.class, MeterQuery.class, TestMeterQuery.class), ImmutableMap.of()));
    meterStore = new DistributedMeterStore();
    TestUtils.setField(meterStore, "storageService", new TestStorageService());
    TestUtils.setField(meterStore, "driverService", driverService);
    KryoNamespace.Builder testKryoBuilder = TestUtils.getField(meterStore, "APP_KRYO_BUILDER");
    testKryoBuilder.register(TestApplicationId.class);
    Serializer testSerializer = Serializer.using(Lists.newArrayList(testKryoBuilder.build()));
    TestUtils.setField(meterStore, "serializer", testSerializer);
    meterStore.activate();
    manager = new MeterManager();
    TestUtils.setField(manager, "store", meterStore);
    injectEventDispatcher(manager, new TestEventDispatcher());
    manager.deviceService = deviceService;
    manager.mastershipService = new TestMastershipService();
    manager.cfgService = new ComponentConfigAdapter();
    manager.clusterService = new TestClusterService();
    registry = manager;
    manager.driverService = driverService;
    Dictionary<String, Object> cfgDict = new Hashtable<>();
    expect(componentContext.getProperties()).andReturn(cfgDict);
    replay(componentContext);
    manager.activate(componentContext);
    provider = new TestProvider(PID);
    providerService = registry.register(provider);
    assertTrue("provider should be registered", registry.getProviders().contains(provider.id()));
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) TestStorageService(org.onosproject.store.service.TestStorageService) Hashtable(java.util.Hashtable) DeviceService(org.onosproject.net.device.DeviceService) DistributedMeterStore(org.onosproject.store.meter.impl.DistributedMeterStore) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) DefaultDriver(org.onosproject.net.driver.DefaultDriver) KryoNamespace(org.onlab.util.KryoNamespace) NetworkConfigServiceAdapter(org.onosproject.net.config.NetworkConfigServiceAdapter) DriverManager(org.onosproject.net.driver.impl.DriverManager) DriverRegistryManager(org.onosproject.net.driver.impl.DriverRegistryManager) Serializer(org.onosproject.store.service.Serializer) Before(org.junit.Before)

Example 12 with Serializer

use of org.onosproject.store.service.Serializer in project onos by opennetworkinglab.

the class MastershipProxyManager method registerProxyService.

@Override
public <T> void registerProxyService(Class<? super T> type, T instance, Serializer serializer) {
    checkArgument(type.isInterface(), "proxy type must be an interface");
    Executor executor = new OrderedExecutor(proxyServiceExecutor);
    services.computeIfAbsent(type, t -> new ProxyService(instance, t, MESSAGE_PREFIX, (i, m, o) -> new SyncOperationService(i, m, o, serializer, executor), (i, m, o) -> new AsyncOperationService(i, m, o, serializer)));
}
Also used : Proxy(java.lang.reflect.Proxy) Tools(org.onlab.util.Tools) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) MastershipProxyService(org.onosproject.mastership.MastershipProxyService) Component(org.osgi.service.component.annotations.Component) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Map(java.util.Map) Activate(org.osgi.service.component.annotations.Activate) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) MastershipService(org.onosproject.mastership.MastershipService) Method(java.lang.reflect.Method) ExecutorService(java.util.concurrent.ExecutorService) NodeId(org.onosproject.cluster.NodeId) Serializer(org.onosproject.store.service.Serializer) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Executor(java.util.concurrent.Executor) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) CompletionException(java.util.concurrent.CompletionException) MastershipProxyFactory(org.onosproject.mastership.MastershipProxyFactory) Maps(com.google.common.collect.Maps) Executors(java.util.concurrent.Executors) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) OrderedExecutor(org.onlab.util.OrderedExecutor) ClusterCommunicationService(org.onosproject.store.cluster.messaging.ClusterCommunicationService) ClusterService(org.onosproject.cluster.ClusterService) DeviceId(org.onosproject.net.DeviceId) Reference(org.osgi.service.component.annotations.Reference) Executor(java.util.concurrent.Executor) OrderedExecutor(org.onlab.util.OrderedExecutor) MastershipProxyService(org.onosproject.mastership.MastershipProxyService) OrderedExecutor(org.onlab.util.OrderedExecutor)

Aggregations

Serializer (org.onosproject.store.service.Serializer)12 Activate (org.osgi.service.component.annotations.Activate)7 NodeId (org.onosproject.cluster.NodeId)5 KryoNamespace (org.onlab.util.KryoNamespace)4 DeviceId (org.onosproject.net.DeviceId)4 Maps (com.google.common.collect.Maps)3 Map (java.util.Map)3 ExecutorService (java.util.concurrent.ExecutorService)3 Executors (java.util.concurrent.Executors)3 Function (java.util.function.Function)3 OrderedExecutor (org.onlab.util.OrderedExecutor)3 Tools.groupedThreads (org.onlab.util.Tools.groupedThreads)3 ClusterCommunicationService (org.onosproject.store.cluster.messaging.ClusterCommunicationService)3 Component (org.osgi.service.component.annotations.Component)3 Deactivate (org.osgi.service.component.annotations.Deactivate)3 Reference (org.osgi.service.component.annotations.Reference)3 ReferenceCardinality (org.osgi.service.component.annotations.ReferenceCardinality)3 Logger (org.slf4j.Logger)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)2 Method (java.lang.reflect.Method)2