use of net.floodlightcontroller.core.module.FloodlightModuleException in project open-kilda by telstra.
the class KafkaMessageCollector method startUp.
@Override
public void startUp(FloodlightModuleContext moduleContext) throws FloodlightModuleException {
ConsumerContext context = new ConsumerContext(moduleContext, this);
RecordHandler.Factory handlerFactory = new RecordHandler.Factory(context);
ISwitchManager switchManager = moduleContext.getServiceImpl(ISwitchManager.class);
logger.info("Starting {}", this.getClass().getCanonicalName());
try {
ExecutorService parseRecordExecutor = Executors.newFixedThreadPool(EXEC_POOL_SIZE);
Consumer consumer;
if (!"YES".equals(context.configLookup("testing-mode"))) {
consumer = new Consumer(context, parseRecordExecutor, handlerFactory, switchManager, INPUT_TOPIC);
} else {
consumer = new TestAwareConsumer(context, parseRecordExecutor, handlerFactory, switchManager, INPUT_TOPIC);
}
Executors.newSingleThreadExecutor().execute(consumer);
} catch (Exception exception) {
logger.error("error", exception);
}
}
use of net.floodlightcontroller.core.module.FloodlightModuleException in project open-kilda by telstra.
the class PathVerificationService method initAlgorithm.
@VisibleForTesting
void initAlgorithm(String secret) throws FloodlightModuleException {
try {
algorithm = Algorithm.HMAC256(secret);
verifier = JWT.require(algorithm).build();
} catch (UnsupportedEncodingException e) {
logger.error("Ivalid secret", e);
throw new FloodlightModuleException("Invalid secret for HMAC256");
}
}
use of net.floodlightcontroller.core.module.FloodlightModuleException in project open-kilda by telstra.
the class StatisticsService method startUp.
@Override
public void startUp(FloodlightModuleContext context) throws FloodlightModuleException {
if (interval > 0) {
threadPoolService.getScheduledExecutor().scheduleAtFixedRate(() -> switchService.getAllSwitchMap().values().forEach(iofSwitch -> {
OFFactory factory = iofSwitch.getOFFactory();
final String switchId = iofSwitch.getId().toString();
OFPortStatsRequest portStatsRequest = factory.buildPortStatsRequest().setPortNo(OFPort.ANY).build();
OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().setOutGroup(OFGroup.ANY).setCookieMask(SYSTEM_MASK).build();
logger.info("Getting port stats for switch={}", iofSwitch.getId());
Futures.addCallback(iofSwitch.writeStatsRequest(portStatsRequest), new RequestCallback<>(data -> {
List<PortStatsReply> replies = data.stream().map(reply -> {
List<PortStatsEntry> entries = reply.getEntries().stream().map(entry -> {
if (entry.getVersion().compareTo(OFVersion.OF_13) > 0) {
long rxFrameErr, rxOverErr, rxCrcErr, collisions;
rxFrameErr = rxOverErr = rxCrcErr = collisions = 0;
for (OFPortStatsProp property : entry.getProperties()) {
if (property.getType() == 0x0) {
OFPortStatsPropEthernet etherProps = (OFPortStatsPropEthernet) property;
rxFrameErr = etherProps.getRxFrameErr().getValue();
rxOverErr = etherProps.getRxOverErr().getValue();
rxCrcErr = etherProps.getRxCrcErr().getValue();
collisions = etherProps.getCollisions().getLength();
}
}
return new PortStatsEntry(entry.getPortNo().getPortNumber(), entry.getRxPackets().getValue(), entry.getTxPackets().getValue(), entry.getRxBytes().getValue(), entry.getTxBytes().getValue(), entry.getRxDropped().getValue(), entry.getTxDropped().getValue(), entry.getRxErrors().getValue(), entry.getTxErrors().getValue(), rxFrameErr, rxOverErr, rxCrcErr, collisions);
} else {
return new PortStatsEntry(entry.getPortNo().getPortNumber(), entry.getRxPackets().getValue(), entry.getTxPackets().getValue(), entry.getRxBytes().getValue(), entry.getTxBytes().getValue(), entry.getRxDropped().getValue(), entry.getTxDropped().getValue(), entry.getRxErrors().getValue(), entry.getTxErrors().getValue(), entry.getRxFrameErr().getValue(), entry.getRxOverErr().getValue(), entry.getRxCrcErr().getValue(), entry.getCollisions().getValue());
}
}).collect(toList());
return new PortStatsReply(reply.getXid(), entries);
}).collect(toList());
return new PortStatsData(switchId, replies);
}, "port"));
if (factory.getVersion().compareTo(OFVersion.OF_15) != 0) {
// skip flow stats for OF 1.5 protocol version
logger.info("Getting flow stats for switch={}", iofSwitch.getId());
Futures.addCallback(iofSwitch.writeStatsRequest(flowStatsRequest), new RequestCallback<>(data -> {
List<FlowStatsReply> replies = data.stream().map(reply -> {
List<FlowStatsEntry> entries = reply.getEntries().stream().map(entry -> new FlowStatsEntry(entry.getTableId().getValue(), entry.getCookie().getValue(), entry.getPacketCount().getValue(), entry.getByteCount().getValue())).collect(toList());
return new FlowStatsReply(reply.getXid(), entries);
}).collect(toList());
return new FlowStatsData(switchId, replies);
}, "flow"));
}
}), interval, interval, TimeUnit.SECONDS);
}
}
use of net.floodlightcontroller.core.module.FloodlightModuleException in project open-kilda by telstra.
the class KafkaMessageProducer method initHeartBeat.
private void initHeartBeat(Context context) throws FloodlightModuleException {
final String option = "heart-beat-interval";
String value = context.configLookup(option);
try {
Float interval = Float.valueOf(context.configLookup(option));
if (interval < 1) {
throw new FloodlightModuleException(String.format("Invalid value for option %s: %s < 1", option, value));
}
heartBeat = new HeartBeat(producer, (long) (interval * 1000));
} catch (NumberFormatException e) {
throw new FloodlightModuleException(String.format("Invalid value for option %s=\"%s\", expect number", option, value));
}
}
Aggregations