Search in sources :

Example 1 with KildaCoreConfig

use of org.openkilda.floodlight.KildaCoreConfig in project open-kilda by telstra.

the class PingCommandTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    FloodlightModuleConfigurationProvider provider = FloodlightModuleConfigurationProvider.of(moduleContext, KildaCore.class);
    KildaCoreConfig coreConfig = provider.getConfiguration(KildaCoreConfig.class);
    expect(kildaCore.getConfig()).andStubReturn(coreConfig);
    moduleContext.addService(KildaCore.class, kildaCore);
    moduleContext.addService(IKafkaProducerService.class, producerService);
    moduleContext.addService(PingService.class, pingService);
    KafkaChannel topics = createMock(KafkaChannel.class);
    expect(topics.getPingTopic()).andReturn(PING_KAFKA_TOPIC).anyTimes();
    KafkaUtilityService kafkaUtility = createMock(KafkaUtilityService.class);
    expect(kafkaUtility.getKafkaChannel()).andReturn(topics).anyTimes();
    moduleContext.addService(KafkaUtilityService.class, kafkaUtility);
    producerService.sendMessageAndTrack(anyString(), capture(kafkaMessageCatcher));
    expectLastCall().andVoid().anyTimes();
}
Also used : FloodlightModuleConfigurationProvider(org.openkilda.floodlight.config.provider.FloodlightModuleConfigurationProvider) KildaCoreConfig(org.openkilda.floodlight.KildaCoreConfig) KafkaChannel(org.openkilda.floodlight.KafkaChannel) KafkaUtilityService(org.openkilda.floodlight.service.kafka.KafkaUtilityService) Before(org.junit.Before)

Example 2 with KildaCoreConfig

use of org.openkilda.floodlight.KildaCoreConfig in project open-kilda by telstra.

the class SwitchManagerTest method setUp.

@Before
public void setUp() throws FloodlightModuleException {
    JdkProxyStaticConfigurationFactory factory = new JdkProxyStaticConfigurationFactory();
    config = factory.createConfiguration(SwitchManagerConfig.class, new MapConfigurationSource(emptyMap()));
    ofSwitchService = createMock(IOFSwitchService.class);
    restApiService = createMock(IRestApiService.class);
    featureDetectorService = createMock(FeatureDetectorService.class);
    switchFlowFactory = new SwitchFlowFactory();
    iofSwitch = createMock(IOFSwitch.class);
    switchDescription = createMock(SwitchDescription.class);
    dpid = DatapathId.of(SWITCH_ID.toLong());
    PathVerificationServiceConfig config = EasyMock.createMock(PathVerificationServiceConfig.class);
    expect(config.getVerificationBcastPacketDst()).andReturn("00:26:E1:FF:FF:FF").anyTimes();
    replay(config);
    PathVerificationService pathVerificationService = EasyMock.createMock(PathVerificationService.class);
    expect(pathVerificationService.getConfig()).andReturn(config).anyTimes();
    replay(pathVerificationService);
    KildaCore kildaCore = EasyMock.createMock(KildaCore.class);
    FloodlightModuleConfigurationProvider provider = FloodlightModuleConfigurationProvider.of(context, KildaCore.class);
    KildaCoreConfig coreConfig = provider.getConfiguration(KildaCoreConfig.class);
    expect(kildaCore.getConfig()).andStubReturn(coreConfig);
    EasyMock.replay(kildaCore);
    context.addService(KildaCore.class, kildaCore);
    SwitchTrackingService switchTracking = createMock(SwitchTrackingService.class);
    switchTracking.setup(context);
    replay(switchTracking);
    context.addService(SwitchTrackingService.class, switchTracking);
    IFloodlightProviderService floodlightProvider = createMock(IFloodlightProviderService.class);
    floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.ERROR), EasyMock.anyObject(SwitchManager.class));
    replay(floodlightProvider);
    context.addService(IFloodlightProviderService.class, floodlightProvider);
    context.addService(IRestApiService.class, restApiService);
    context.addService(IOFSwitchService.class, ofSwitchService);
    context.addService(FeatureDetectorService.class, featureDetectorService);
    context.addService(SwitchFlowFactory.class, switchFlowFactory);
    context.addService(IPathVerificationService.class, pathVerificationService);
    switchManager = new SwitchManager();
    context.addService(ISwitchManager.class, switchManager);
    switchManager.init(context);
    switchManager.startUp(context);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) PathVerificationServiceConfig(org.openkilda.floodlight.pathverification.PathVerificationServiceConfig) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) IFloodlightProviderService(net.floodlightcontroller.core.IFloodlightProviderService) KildaCore(org.openkilda.floodlight.KildaCore) FloodlightModuleConfigurationProvider(org.openkilda.floodlight.config.provider.FloodlightModuleConfigurationProvider) IRestApiService(net.floodlightcontroller.restserver.IRestApiService) PathVerificationService(org.openkilda.floodlight.pathverification.PathVerificationService) IPathVerificationService(org.openkilda.floodlight.pathverification.IPathVerificationService) JdkProxyStaticConfigurationFactory(com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory) MapConfigurationSource(com.sabre.oss.conf4j.source.MapConfigurationSource) KildaCoreConfig(org.openkilda.floodlight.KildaCoreConfig) SwitchDescription(net.floodlightcontroller.core.SwitchDescription) SwitchFlowFactory(org.openkilda.floodlight.switchmanager.factory.SwitchFlowFactory) Before(org.junit.Before)

Example 3 with KildaCoreConfig

use of org.openkilda.floodlight.KildaCoreConfig in project open-kilda by telstra.

the class PingService method setup.

/**
 * Initialize internal data structures. Called by module that own this service. Called after all dependencies have
 * been loaded.
 */
@Override
public void setup(FloodlightModuleContext moduleContext) throws FloodlightModuleException {
    // FIXME(surabujin): avoid usage foreign module configuration
    Map<String, String> config = moduleContext.getConfigParams(PathVerificationService.class);
    try {
        signature = new DataSignature(config.get("hmac256-secret"));
    } catch (InvalidSignatureConfigurationException e) {
        throw new FloodlightModuleException(String.format("Unable to initialize %s", getClass().getName()), e);
    }
    InputService inputService = moduleContext.getServiceImpl(InputService.class);
    inputService.addTranslator(OFType.PACKET_IN, new PingInputTranslator());
    KildaCoreConfig coreConfig = moduleContext.getServiceImpl(KildaCore.class).getConfig();
    magicSourceMacAddress = MacAddress.of(coreConfig.getFlowPingMagicSrcMacAddress());
}
Also used : InputService(org.openkilda.floodlight.service.of.InputService) FloodlightModuleException(net.floodlightcontroller.core.module.FloodlightModuleException) InvalidSignatureConfigurationException(org.openkilda.floodlight.error.InvalidSignatureConfigurationException) KildaCoreConfig(org.openkilda.floodlight.KildaCoreConfig) KildaCore(org.openkilda.floodlight.KildaCore) DataSignature(org.openkilda.floodlight.utils.DataSignature)

Example 4 with KildaCoreConfig

use of org.openkilda.floodlight.KildaCoreConfig in project open-kilda by telstra.

the class CommandProcessorService method setup.

/**
 * Service initialize(late) method.
 */
@Override
public void setup(FloodlightModuleContext moduleContext) {
    KildaCoreConfig config = kildaCore.getConfig();
    log.info("config - persistent workers = {}", config.getCommandPersistentWorkersCount());
    log.info("config - workers limit = {}", config.getCommandWorkersLimit());
    log.info("config - idle workers keep alive seconds = {}", config.getCommandIdleWorkersKeepAliveSeconds());
    log.info("config - deferred requests limit = {}", config.getCommandDeferredRequestsLimit());
    executor = new ThreadPoolExecutor(config.getCommandPersistentWorkersCount(), config.getCommandWorkersLimit(), config.getCommandIdleWorkersKeepAliveSeconds(), TimeUnit.SECONDS, new ArrayBlockingQueue<>(config.getCommandDeferredRequestsLimit()), new RejectedExecutor(this));
    executor.prestartAllCoreThreads();
    scheduleFutureCheckTrigger(moduleContext.getServiceImpl(IThreadPoolService.class).getScheduledExecutor());
}
Also used : ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) KildaCoreConfig(org.openkilda.floodlight.KildaCoreConfig) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 5 with KildaCoreConfig

use of org.openkilda.floodlight.KildaCoreConfig in project open-kilda by telstra.

the class PingServiceTest method setUp.

@Before
public void setUp() {
    injectMocks(this);
    KildaCore kildaCore = EasyMock.createMock(KildaCore.class);
    FloodlightModuleConfigurationProvider provider = FloodlightModuleConfigurationProvider.of(moduleContext, KildaCore.class);
    KildaCoreConfig coreConfig = provider.getConfiguration(KildaCoreConfig.class);
    expect(kildaCore.getConfig()).andStubReturn(coreConfig);
    EasyMock.replay(kildaCore);
    moduleContext.addService(KildaCore.class, kildaCore);
    moduleContext.addService(IOFSwitchService.class, createMock(IOFSwitchService.class));
    moduleContext.addService(InputService.class, createMock(InputService.class));
    moduleContext.addService(ISwitchManager.class, createMock(ISwitchManager.class));
    moduleContext.addConfigParam(pathVerificationService, "hmac256-secret", "secret");
}
Also used : FloodlightModuleConfigurationProvider(org.openkilda.floodlight.config.provider.FloodlightModuleConfigurationProvider) InputService(org.openkilda.floodlight.service.of.InputService) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) KildaCoreConfig(org.openkilda.floodlight.KildaCoreConfig) KildaCore(org.openkilda.floodlight.KildaCore) Before(org.junit.Before)

Aggregations

KildaCoreConfig (org.openkilda.floodlight.KildaCoreConfig)6 Before (org.junit.Before)4 KildaCore (org.openkilda.floodlight.KildaCore)3 FloodlightModuleConfigurationProvider (org.openkilda.floodlight.config.provider.FloodlightModuleConfigurationProvider)3 IOFSwitchService (net.floodlightcontroller.core.internal.IOFSwitchService)2 InputService (org.openkilda.floodlight.service.of.InputService)2 JdkProxyStaticConfigurationFactory (com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory)1 MapConfigurationSource (com.sabre.oss.conf4j.source.MapConfigurationSource)1 Properties (java.util.Properties)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 IFloodlightProviderService (net.floodlightcontroller.core.IFloodlightProviderService)1 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)1 FloodlightModuleException (net.floodlightcontroller.core.module.FloodlightModuleException)1 IRestApiService (net.floodlightcontroller.restserver.IRestApiService)1 PropertiesBasedConfigurationProvider (org.openkilda.config.provider.PropertiesBasedConfigurationProvider)1 KafkaChannel (org.openkilda.floodlight.KafkaChannel)1 InvalidSignatureConfigurationException (org.openkilda.floodlight.error.InvalidSignatureConfigurationException)1 IPathVerificationService (org.openkilda.floodlight.pathverification.IPathVerificationService)1