target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void convertFlowWithIngressVlanIdMatchesTransitVlanId() { Flow flow = buildFlow(FlowEncapsulationType.TRANSIT_VLAN); Assert.assertNotEquals(0, flow.getSrcVlan()); Assert.assertNotNull(flow.getForwardPath()); TransitVlan encapsulation = TransitVlan.builder() .flowId(flow.getFlowId()) .pathId(flow.getForwardPathId()) .vlan(flow.getSrcVlan()) .build(); List<SimpleSwitchRule> pathView = simpleSwitchRuleConverter.convertFlowPathToSimpleSwitchRules( flow, flow.getForwardPath(), encapsulation, MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT); Assert.assertFalse(pathView.isEmpty()); SimpleSwitchRule ingress = pathView.get(0); Assert.assertEquals(Collections.emptyList(), ingress.getOutVlan()); }
|
public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
@Test public void shouldConvertFlowPathWithVxlanEncapToSimpleSwitchRules() { Flow flow = buildFlow(FlowEncapsulationType.VXLAN); List<SimpleSwitchRule> expectedSwitchRules = getSimpleSwitchRuleForVxlan(); List<SimpleSwitchRule> switchRules = simpleSwitchRuleConverter.convertFlowPathToSimpleSwitchRules(flow, flow.getForwardPath(), Vxlan.builder() .flowId(TEST_FLOW_ID_A) .pathId(FLOW_A_FORWARD_PATH_ID) .vni(FLOW_A_ENCAP_ID) .build(), MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT); assertEquals(expectedSwitchRules, switchRules); }
|
public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
@Test public void shouldConvertFlowPathOneSwitchFlowToSimpleSwitchRules() { Flow flow = buildOneSwitchPortFlow(); List<SimpleSwitchRule> expectedSwitchRules = getSimpleSwitchRuleForOneSwitchFlow(); List<SimpleSwitchRule> switchRules = simpleSwitchRuleConverter.convertFlowPathToSimpleSwitchRules(flow, flow.getForwardPath(), null, MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT); assertEquals(expectedSwitchRules, switchRules); }
|
public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) { List<SimpleSwitchRule> rules = new ArrayList<>(); if (!flowPath.isProtected()) { rules.add(buildIngressSimpleSwitchRule(flow, flowPath, encapsulationId, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient)); } if (! flow.isOneSwitchFlow()) { rules.addAll(buildTransitAndEgressSimpleSwitchRules(flow, flowPath, encapsulationId)); } return rules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
@Test public void shouldConvertFlowEntriesTransitVlanFlowToSimpleSwitchRules() { List<SimpleSwitchRule> expectedSwitchRules = getSimpleSwitchRuleForTransitVlan(); List<SwitchFlowEntries> switchFlowEntries = getSwitchFlowEntriesWithTransitVlan(); List<SwitchMeterEntries> switchMeterEntries = getSwitchMeterEntries(); for (int i = 0; i < switchFlowEntries.size(); i++) { List<SimpleSwitchRule> switchRules = simpleSwitchRuleConverter.convertSwitchFlowEntriesToSimpleSwitchRules(switchFlowEntries.get(i), switchMeterEntries.get(i)); assertThat(switchRules, hasSize(1)); assertEquals(expectedSwitchRules.get(i), switchRules.get(0)); } }
|
public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
@Test public void shouldConvertFlowEntriesVxlanFlowToSimpleSwitchRules() { List<SimpleSwitchRule> expectedSwitchRules = getSimpleSwitchRuleForVxlan(); List<SwitchFlowEntries> switchFlowEntries = getSwitchFlowEntriesWithVxlan(); List<SwitchMeterEntries> switchMeterEntries = getSwitchMeterEntries(); for (int i = 0; i < switchFlowEntries.size(); i++) { List<SimpleSwitchRule> switchRules = simpleSwitchRuleConverter.convertSwitchFlowEntriesToSimpleSwitchRules(switchFlowEntries.get(i), switchMeterEntries.get(i)); assertThat(switchRules, hasSize(1)); assertEquals(expectedSwitchRules.get(i), switchRules.get(0)); } }
|
public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
@Test(expected = IslNotFoundException.class) public void shouldFailIfThereIsNoIslForBfdEnableFlagUpdateRequest() throws IslNotFoundException { linkOperationsService.updateEnableBfdFlag( Endpoint.of(TEST_SWITCH_A_ID, TEST_SWITCH_A_PORT), Endpoint.of(TEST_SWITCH_B_ID, TEST_SWITCH_B_PORT), true); }
|
public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); }
|
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } }
|
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } LinkOperationsService(ILinkOperationsServiceCarrier carrier,
RepositoryFactory repositoryFactory,
TransactionManager transactionManager); }
|
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } LinkOperationsService(ILinkOperationsServiceCarrier carrier,
RepositoryFactory repositoryFactory,
TransactionManager transactionManager); List<Isl> updateLinkUnderMaintenanceFlag(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort,
boolean underMaintenance); Collection<Isl> getAllIsls(SwitchId srcSwitch, Integer srcPort,
SwitchId dstSwitch, Integer dstPort); Collection<Isl> deleteIsl(SwitchId sourceSwitch, int sourcePort, SwitchId destinationSwitch,
int destinationPort, boolean force); Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue); }
|
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } LinkOperationsService(ILinkOperationsServiceCarrier carrier,
RepositoryFactory repositoryFactory,
TransactionManager transactionManager); List<Isl> updateLinkUnderMaintenanceFlag(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort,
boolean underMaintenance); Collection<Isl> getAllIsls(SwitchId srcSwitch, Integer srcPort,
SwitchId dstSwitch, Integer dstPort); Collection<Isl> deleteIsl(SwitchId sourceSwitch, int sourcePort, SwitchId destinationSwitch,
int destinationPort, boolean force); Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue); }
|
@Test public void shouldConvertFlowEntriesOneSwitchFlowToSimpleSwitchRules() { List<SimpleSwitchRule> expectedSwitchRules = getSimpleSwitchRuleForOneSwitchFlow(); List<SwitchFlowEntries> switchFlowEntries = getSwitchFlowEntriesOneSwitchFlow(); List<SimpleSwitchRule> switchRules = simpleSwitchRuleConverter.convertSwitchFlowEntriesToSimpleSwitchRules(switchFlowEntries.get(0), getSwitchMeterEntriesOneSwitchFlow()); assertEquals(expectedSwitchRules, switchRules); }
|
public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
SimpleSwitchRuleConverter { public List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules, SwitchMeterEntries meters) { if (rules == null || rules.getFlowEntries() == null) { return Collections.emptyList(); } List<SimpleSwitchRule> simpleRules = new ArrayList<>(); for (FlowEntry flowEntry : rules.getFlowEntries()) { simpleRules.add(buildSimpleSwitchRule(rules.getSwitchId(), flowEntry, meters)); } return simpleRules; } List<SimpleSwitchRule> convertFlowPathToSimpleSwitchRules(Flow flow, FlowPath flowPath,
EncapsulationId encapsulationId,
long flowMeterMinBurstSizeInKbits,
double flowMeterBurstCoefficient); List<SimpleSwitchRule> convertSwitchFlowEntriesToSimpleSwitchRules(SwitchFlowEntries rules,
SwitchMeterEntries meters); }
|
@Test public void cookiePool() { transactionManager.doInTransaction(() -> { Set<Long> cookies = new HashSet<>(); for (long i = MIN_COOKIE; i <= MAX_COOKIE; i++) { cookies.add(cookiePool.allocate(format("flow_%d", i))); } assertEquals(MAX_COOKIE - MIN_COOKIE + 1, cookies.size()); cookies.forEach(cookie -> assertTrue(cookie >= MIN_COOKIE && cookie <= MAX_COOKIE)); }); }
|
public CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize) { transactionManager = persistenceManager.getTransactionManager(); RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory(); flowCookieRepository = repositoryFactory.createFlowCookieRepository(); this.minCookie = minCookie; this.maxCookie = maxCookie; this.poolSize = poolSize; }
|
CookiePool { public CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize) { transactionManager = persistenceManager.getTransactionManager(); RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory(); flowCookieRepository = repositoryFactory.createFlowCookieRepository(); this.minCookie = minCookie; this.maxCookie = maxCookie; this.poolSize = poolSize; } }
|
CookiePool { public CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize) { transactionManager = persistenceManager.getTransactionManager(); RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory(); flowCookieRepository = repositoryFactory.createFlowCookieRepository(); this.minCookie = minCookie; this.maxCookie = maxCookie; this.poolSize = poolSize; } CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize); }
|
CookiePool { public CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize) { transactionManager = persistenceManager.getTransactionManager(); RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory(); flowCookieRepository = repositoryFactory.createFlowCookieRepository(); this.minCookie = minCookie; this.maxCookie = maxCookie; this.poolSize = poolSize; } CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize); @TransactionRequired long allocate(String flowId); void deallocate(long unmaskedCookie); }
|
CookiePool { public CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize) { transactionManager = persistenceManager.getTransactionManager(); RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory(); flowCookieRepository = repositoryFactory.createFlowCookieRepository(); this.minCookie = minCookie; this.maxCookie = maxCookie; this.poolSize = poolSize; } CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize); @TransactionRequired long allocate(String flowId); void deallocate(long unmaskedCookie); }
|
@Test(expected = ResourceNotAvailableException.class) public void cookiePoolFullTest() { transactionManager.doInTransaction(() -> { for (long i = MIN_COOKIE; i <= MAX_COOKIE + 1; i++) { assertTrue(cookiePool.allocate(format("flow_%d", i)) > 0); } }); }
|
@TransactionRequired public long allocate(String flowId) { if (nextCookie > 0) { if (nextCookie <= maxCookie && !flowCookieRepository.exists(nextCookie)) { addCookie(flowId, nextCookie); return nextCookie++; } else { nextCookie = 0; } } if (nextCookie == 0) { long numOfPools = (maxCookie - minCookie) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie( minCookie + poolToTake * poolSize, minCookie + (poolToTake + 1) * poolSize - 1); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } nextCookie = -1; } if (nextCookie == -1) { Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie(minCookie, maxCookie); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } throw new ResourceNotAvailableException("No cookie available"); }
|
CookiePool { @TransactionRequired public long allocate(String flowId) { if (nextCookie > 0) { if (nextCookie <= maxCookie && !flowCookieRepository.exists(nextCookie)) { addCookie(flowId, nextCookie); return nextCookie++; } else { nextCookie = 0; } } if (nextCookie == 0) { long numOfPools = (maxCookie - minCookie) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie( minCookie + poolToTake * poolSize, minCookie + (poolToTake + 1) * poolSize - 1); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } nextCookie = -1; } if (nextCookie == -1) { Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie(minCookie, maxCookie); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } throw new ResourceNotAvailableException("No cookie available"); } }
|
CookiePool { @TransactionRequired public long allocate(String flowId) { if (nextCookie > 0) { if (nextCookie <= maxCookie && !flowCookieRepository.exists(nextCookie)) { addCookie(flowId, nextCookie); return nextCookie++; } else { nextCookie = 0; } } if (nextCookie == 0) { long numOfPools = (maxCookie - minCookie) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie( minCookie + poolToTake * poolSize, minCookie + (poolToTake + 1) * poolSize - 1); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } nextCookie = -1; } if (nextCookie == -1) { Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie(minCookie, maxCookie); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } throw new ResourceNotAvailableException("No cookie available"); } CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize); }
|
CookiePool { @TransactionRequired public long allocate(String flowId) { if (nextCookie > 0) { if (nextCookie <= maxCookie && !flowCookieRepository.exists(nextCookie)) { addCookie(flowId, nextCookie); return nextCookie++; } else { nextCookie = 0; } } if (nextCookie == 0) { long numOfPools = (maxCookie - minCookie) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie( minCookie + poolToTake * poolSize, minCookie + (poolToTake + 1) * poolSize - 1); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } nextCookie = -1; } if (nextCookie == -1) { Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie(minCookie, maxCookie); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } throw new ResourceNotAvailableException("No cookie available"); } CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize); @TransactionRequired long allocate(String flowId); void deallocate(long unmaskedCookie); }
|
CookiePool { @TransactionRequired public long allocate(String flowId) { if (nextCookie > 0) { if (nextCookie <= maxCookie && !flowCookieRepository.exists(nextCookie)) { addCookie(flowId, nextCookie); return nextCookie++; } else { nextCookie = 0; } } if (nextCookie == 0) { long numOfPools = (maxCookie - minCookie) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie( minCookie + poolToTake * poolSize, minCookie + (poolToTake + 1) * poolSize - 1); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } nextCookie = -1; } if (nextCookie == -1) { Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie(minCookie, maxCookie); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } throw new ResourceNotAvailableException("No cookie available"); } CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize); @TransactionRequired long allocate(String flowId); void deallocate(long unmaskedCookie); }
|
@Test public void cookieLldp() { transactionManager.doInTransaction(() -> { String flowId = "flow_1"; long flowCookie = cookiePool.allocate(flowId); long lldpCookie = cookiePool.allocate(flowId); assertNotEquals(flowCookie, lldpCookie); }); }
|
@TransactionRequired public long allocate(String flowId) { if (nextCookie > 0) { if (nextCookie <= maxCookie && !flowCookieRepository.exists(nextCookie)) { addCookie(flowId, nextCookie); return nextCookie++; } else { nextCookie = 0; } } if (nextCookie == 0) { long numOfPools = (maxCookie - minCookie) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie( minCookie + poolToTake * poolSize, minCookie + (poolToTake + 1) * poolSize - 1); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } nextCookie = -1; } if (nextCookie == -1) { Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie(minCookie, maxCookie); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } throw new ResourceNotAvailableException("No cookie available"); }
|
CookiePool { @TransactionRequired public long allocate(String flowId) { if (nextCookie > 0) { if (nextCookie <= maxCookie && !flowCookieRepository.exists(nextCookie)) { addCookie(flowId, nextCookie); return nextCookie++; } else { nextCookie = 0; } } if (nextCookie == 0) { long numOfPools = (maxCookie - minCookie) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie( minCookie + poolToTake * poolSize, minCookie + (poolToTake + 1) * poolSize - 1); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } nextCookie = -1; } if (nextCookie == -1) { Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie(minCookie, maxCookie); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } throw new ResourceNotAvailableException("No cookie available"); } }
|
CookiePool { @TransactionRequired public long allocate(String flowId) { if (nextCookie > 0) { if (nextCookie <= maxCookie && !flowCookieRepository.exists(nextCookie)) { addCookie(flowId, nextCookie); return nextCookie++; } else { nextCookie = 0; } } if (nextCookie == 0) { long numOfPools = (maxCookie - minCookie) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie( minCookie + poolToTake * poolSize, minCookie + (poolToTake + 1) * poolSize - 1); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } nextCookie = -1; } if (nextCookie == -1) { Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie(minCookie, maxCookie); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } throw new ResourceNotAvailableException("No cookie available"); } CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize); }
|
CookiePool { @TransactionRequired public long allocate(String flowId) { if (nextCookie > 0) { if (nextCookie <= maxCookie && !flowCookieRepository.exists(nextCookie)) { addCookie(flowId, nextCookie); return nextCookie++; } else { nextCookie = 0; } } if (nextCookie == 0) { long numOfPools = (maxCookie - minCookie) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie( minCookie + poolToTake * poolSize, minCookie + (poolToTake + 1) * poolSize - 1); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } nextCookie = -1; } if (nextCookie == -1) { Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie(minCookie, maxCookie); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } throw new ResourceNotAvailableException("No cookie available"); } CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize); @TransactionRequired long allocate(String flowId); void deallocate(long unmaskedCookie); }
|
CookiePool { @TransactionRequired public long allocate(String flowId) { if (nextCookie > 0) { if (nextCookie <= maxCookie && !flowCookieRepository.exists(nextCookie)) { addCookie(flowId, nextCookie); return nextCookie++; } else { nextCookie = 0; } } if (nextCookie == 0) { long numOfPools = (maxCookie - minCookie) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie( minCookie + poolToTake * poolSize, minCookie + (poolToTake + 1) * poolSize - 1); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } nextCookie = -1; } if (nextCookie == -1) { Optional<Long> availableCookie = flowCookieRepository.findFirstUnassignedCookie(minCookie, maxCookie); if (availableCookie.isPresent()) { nextCookie = availableCookie.get(); addCookie(flowId, nextCookie); return nextCookie++; } } throw new ResourceNotAvailableException("No cookie available"); } CookiePool(PersistenceManager persistenceManager, long minCookie, long maxCookie, int poolSize); @TransactionRequired long allocate(String flowId); void deallocate(long unmaskedCookie); }
|
@Test public void shouldAllocateForFlow() throws ResourceAllocationException { transactionManager.doInTransaction(() -> { Flow flow = convertFlow(firstFlow); verifyAllocation(resourcesManager.allocateFlowResources(flow)); }); }
|
public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
PathId oppositePathId,
FlowEncapsulationType encapsulationType); }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
PathId oppositePathId,
FlowEncapsulationType encapsulationType); }
|
@Test public void shouldAllocateForNoBandwidthFlow() throws ResourceAllocationException { transactionManager.doInTransaction(() -> { Flow flow = convertFlow(fourthFlow); verifyMeterLessAllocation(resourcesManager.allocateFlowResources(flow)); }); }
|
public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
PathId oppositePathId,
FlowEncapsulationType encapsulationType); }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
PathId oppositePathId,
FlowEncapsulationType encapsulationType); }
|
@Test public void shouldNotConsumeVlansForSingleSwitchFlows() throws ResourceAllocationException { transactionManager.doInTransaction(() -> { final int attemps = (flowResourcesConfig.getMaxFlowTransitVlan() - flowResourcesConfig.getMinFlowTransitVlan()) / 2 + 1; for (int i = 0; i < attemps; i++) { thirdFlow.setFlowId(format("third-flow-%d", i)); Flow flow3 = convertFlow(thirdFlow); resourcesManager.allocateFlowResources(flow3); } }); }
|
public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
PathId oppositePathId,
FlowEncapsulationType encapsulationType); }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
PathId oppositePathId,
FlowEncapsulationType encapsulationType); }
|
@Test public void shouldNotConsumeMetersForUnmeteredFlows() throws ResourceAllocationException { transactionManager.doInTransaction(() -> { final int attemps = (flowResourcesConfig.getMaxFlowMeterId() - flowResourcesConfig.getMinFlowMeterId()) / 2 + 1; for (int i = 0; i < attemps; i++) { fourthFlow.setFlowId(format("fourth-flow-%d", i)); Flow flow4 = convertFlow(fourthFlow); resourcesManager.allocateFlowResources(flow4); } }); }
|
public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
PathId oppositePathId,
FlowEncapsulationType encapsulationType); }
|
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
PathId oppositePathId,
FlowEncapsulationType encapsulationType); }
|
@Test public void deallocatePathResourcesTest() throws Exception { transactionManager.doInTransaction(() -> { Flow flow = convertFlow(firstFlow); FlowResources resources = resourcesManager.allocateFlowResources(flow); resourcesManager.deallocatePathResources(resources.getForward().getPathId(), resources.getUnmaskedCookie(), flow.getEncapsulationType()); resourcesManager.deallocatePathResources(resources.getReverse().getPathId(), resources.getUnmaskedCookie(), flow.getEncapsulationType()); verifyResourcesDeallocation(); }); }
|
public void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType) { log.debug("Deallocate flow resources for path {}, cookie: {}.", pathId, unmaskedCookie); transactionManager.doInTransaction(() -> { cookiePool.deallocate(unmaskedCookie); meterPool.deallocate(pathId); EncapsulationResourcesProvider encapsulationResourcesProvider = getEncapsulationResourcesProvider(encapsulationType); encapsulationResourcesProvider.deallocate(pathId); }); }
|
FlowResourcesManager { public void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType) { log.debug("Deallocate flow resources for path {}, cookie: {}.", pathId, unmaskedCookie); transactionManager.doInTransaction(() -> { cookiePool.deallocate(unmaskedCookie); meterPool.deallocate(pathId); EncapsulationResourcesProvider encapsulationResourcesProvider = getEncapsulationResourcesProvider(encapsulationType); encapsulationResourcesProvider.deallocate(pathId); }); } }
|
FlowResourcesManager { public void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType) { log.debug("Deallocate flow resources for path {}, cookie: {}.", pathId, unmaskedCookie); transactionManager.doInTransaction(() -> { cookiePool.deallocate(unmaskedCookie); meterPool.deallocate(pathId); EncapsulationResourcesProvider encapsulationResourcesProvider = getEncapsulationResourcesProvider(encapsulationType); encapsulationResourcesProvider.deallocate(pathId); }); } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); }
|
FlowResourcesManager { public void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType) { log.debug("Deallocate flow resources for path {}, cookie: {}.", pathId, unmaskedCookie); transactionManager.doInTransaction(() -> { cookiePool.deallocate(unmaskedCookie); meterPool.deallocate(pathId); EncapsulationResourcesProvider encapsulationResourcesProvider = getEncapsulationResourcesProvider(encapsulationType); encapsulationResourcesProvider.deallocate(pathId); }); } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
PathId oppositePathId,
FlowEncapsulationType encapsulationType); }
|
FlowResourcesManager { public void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType) { log.debug("Deallocate flow resources for path {}, cookie: {}.", pathId, unmaskedCookie); transactionManager.doInTransaction(() -> { cookiePool.deallocate(unmaskedCookie); meterPool.deallocate(pathId); EncapsulationResourcesProvider encapsulationResourcesProvider = getEncapsulationResourcesProvider(encapsulationType); encapsulationResourcesProvider.deallocate(pathId); }); } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
PathId oppositePathId,
FlowEncapsulationType encapsulationType); }
|
@Test public void vlanPoolTest() { transactionManager.doInTransaction(() -> { Set<Integer> transitVlans = new HashSet<>(); for (int i = MIN_TRANSIT_VLAN; i <= MAX_TRANSIT_VLAN; i++) { Flow flow = Flow.builder() .flowId(format("flow_%d", i)).srcSwitch(SWITCH_A).destSwitch(SWITCH_B).build(); transitVlans.add(transitVlanPool.allocate( flow, new PathId(format("path_%d", i)), new PathId(format("opposite_dummy_%d", i))).getTransitVlan().getVlan()); } assertEquals(MAX_TRANSIT_VLAN - MIN_TRANSIT_VLAN + 1, transitVlans.size()); transitVlans.forEach(vlan -> assertTrue(vlan >= MIN_TRANSIT_VLAN && vlan <= MAX_TRANSIT_VLAN)); }); }
|
@Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } TransitVlanPool(PersistenceManager persistenceManager, int minTransitVlan, int maxTransitVlan,
int poolSize); }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } TransitVlanPool(PersistenceManager persistenceManager, int minTransitVlan, int maxTransitVlan,
int poolSize); @Override TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<TransitVlanEncapsulation> get(PathId pathId, PathId oppositePathId); }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } TransitVlanPool(PersistenceManager persistenceManager, int minTransitVlan, int maxTransitVlan,
int poolSize); @Override TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<TransitVlanEncapsulation> get(PathId pathId, PathId oppositePathId); }
|
@Test(expected = IslNotFoundException.class) public void shouldFailIfThereIsUniIslOnlyForBfdEnableFlagUpdateRequest() throws IslNotFoundException { Isl isl = Isl.builder() .srcSwitch(createSwitchIfNotExist(TEST_SWITCH_A_ID)) .srcPort(TEST_SWITCH_A_PORT) .destSwitch(createSwitchIfNotExist(TEST_SWITCH_B_ID)) .destPort(TEST_SWITCH_B_PORT) .cost(0) .status(IslStatus.ACTIVE) .build(); islRepository.add(isl); linkOperationsService.updateEnableBfdFlag( Endpoint.of(TEST_SWITCH_A_ID, TEST_SWITCH_A_PORT), Endpoint.of(TEST_SWITCH_B_ID, TEST_SWITCH_B_PORT), true); }
|
public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); }
|
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } }
|
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } LinkOperationsService(ILinkOperationsServiceCarrier carrier,
RepositoryFactory repositoryFactory,
TransactionManager transactionManager); }
|
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } LinkOperationsService(ILinkOperationsServiceCarrier carrier,
RepositoryFactory repositoryFactory,
TransactionManager transactionManager); List<Isl> updateLinkUnderMaintenanceFlag(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort,
boolean underMaintenance); Collection<Isl> getAllIsls(SwitchId srcSwitch, Integer srcPort,
SwitchId dstSwitch, Integer dstPort); Collection<Isl> deleteIsl(SwitchId sourceSwitch, int sourcePort, SwitchId destinationSwitch,
int destinationPort, boolean force); Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue); }
|
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } LinkOperationsService(ILinkOperationsServiceCarrier carrier,
RepositoryFactory repositoryFactory,
TransactionManager transactionManager); List<Isl> updateLinkUnderMaintenanceFlag(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort,
boolean underMaintenance); Collection<Isl> getAllIsls(SwitchId srcSwitch, Integer srcPort,
SwitchId dstSwitch, Integer dstPort); Collection<Isl> deleteIsl(SwitchId sourceSwitch, int sourcePort, SwitchId destinationSwitch,
int destinationPort, boolean force); Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue); }
|
@Test(expected = ResourceNotAvailableException.class) public void vlanPoolFullTest() { transactionManager.doInTransaction(() -> { for (int i = MIN_TRANSIT_VLAN; i <= MAX_TRANSIT_VLAN + 1; i++) { Flow flow = Flow.builder() .flowId(format("flow_%d", i)).srcSwitch(SWITCH_A).destSwitch(SWITCH_B).build(); assertTrue(transitVlanPool.allocate( flow, new PathId(format("path_%d", i)), new PathId(format("opposite_dummy_%d", i))).getTransitVlan().getVlan() > 0); } }); }
|
@Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } TransitVlanPool(PersistenceManager persistenceManager, int minTransitVlan, int maxTransitVlan,
int poolSize); }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } TransitVlanPool(PersistenceManager persistenceManager, int minTransitVlan, int maxTransitVlan,
int poolSize); @Override TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<TransitVlanEncapsulation> get(PathId pathId, PathId oppositePathId); }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } TransitVlanPool(PersistenceManager persistenceManager, int minTransitVlan, int maxTransitVlan,
int poolSize); @Override TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<TransitVlanEncapsulation> get(PathId pathId, PathId oppositePathId); }
|
@Test public void gotSameVlanForOppositePath() { Flow flow = Flow.builder().flowId("flow_1").srcSwitch(SWITCH_A).destSwitch(SWITCH_B).build(); final PathId forwardPathId = new PathId("forward"); final PathId reversePathId = new PathId("reverse"); transactionManager.doInTransaction(() -> { TransitVlan forward = transitVlanPool.allocate(flow, forwardPathId, reversePathId) .getTransitVlan(); TransitVlan reverse = transitVlanPool.allocate(flow, reversePathId, forwardPathId) .getTransitVlan(); Assert.assertEquals(forward, reverse); }); }
|
@Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } TransitVlanPool(PersistenceManager persistenceManager, int minTransitVlan, int maxTransitVlan,
int poolSize); }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } TransitVlanPool(PersistenceManager persistenceManager, int minTransitVlan, int maxTransitVlan,
int poolSize); @Override TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<TransitVlanEncapsulation> get(PathId pathId, PathId oppositePathId); }
|
TransitVlanPool implements EncapsulationResourcesProvider<TransitVlanEncapsulation> { @Override public TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } TransitVlanPool(PersistenceManager persistenceManager, int minTransitVlan, int maxTransitVlan,
int poolSize); @Override TransitVlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<TransitVlanEncapsulation> get(PathId pathId, PathId oppositePathId); }
|
@Test public void vxlanIdPool() { transactionManager.doInTransaction(() -> { Set<Integer> vxlans = new HashSet<>(); for (int i = MIN_VXLAN; i <= MAX_VXLAN; i++) { Flow flow = Flow.builder() .flowId(format("flow_%d", i)).srcSwitch(SWITCH_A).destSwitch(SWITCH_B).build(); vxlans.add(vxlanPool.allocate( flow, new PathId(format("path_%d", i)), new PathId(format("opposite_dummy_%d", i))).getVxlan().getVni()); } assertEquals(MAX_VXLAN - MIN_VXLAN + 1, vxlans.size()); vxlans.forEach(vni -> assertTrue(vni >= MIN_VXLAN && vni <= MAX_VXLAN)); }); }
|
@Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); }
|
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } }
|
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } VxlanPool(PersistenceManager persistenceManager, int minVxlan, int maxVxlan, int poolSize); }
|
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } VxlanPool(PersistenceManager persistenceManager, int minVxlan, int maxVxlan, int poolSize); @Override VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<VxlanEncapsulation> get(PathId pathId, PathId oppositePathId); }
|
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } VxlanPool(PersistenceManager persistenceManager, int minVxlan, int maxVxlan, int poolSize); @Override VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<VxlanEncapsulation> get(PathId pathId, PathId oppositePathId); }
|
@Test(expected = ResourceNotAvailableException.class) public void vxlanPoolFullTest() { transactionManager.doInTransaction(() -> { for (int i = MIN_VXLAN; i <= MAX_VXLAN + 1; i++) { Flow flow = Flow.builder() .flowId(format("flow_%d", i)).srcSwitch(SWITCH_A).destSwitch(SWITCH_B).build(); assertTrue(vxlanPool.allocate(flow, new PathId(format("path_%d", i)), new PathId(format("op_path_%d", i))).getVxlan().getVni() > 0); } }); }
|
@Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); }
|
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } }
|
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } VxlanPool(PersistenceManager persistenceManager, int minVxlan, int maxVxlan, int poolSize); }
|
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } VxlanPool(PersistenceManager persistenceManager, int minVxlan, int maxVxlan, int poolSize); @Override VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<VxlanEncapsulation> get(PathId pathId, PathId oppositePathId); }
|
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } VxlanPool(PersistenceManager persistenceManager, int minVxlan, int maxVxlan, int poolSize); @Override VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<VxlanEncapsulation> get(PathId pathId, PathId oppositePathId); }
|
@Test public void meterPoolTest() { transactionManager.doInTransaction(() -> { long minMeterId = MIN_METER_ID.getValue(); long maxMeterId = MAX_METER_ID.getValue(); Set<MeterId> meterIds = new HashSet<>(); for (long i = minMeterId; i <= maxMeterId; i++) { meterIds.add(meterPool.allocate(SWITCH_ID, format("flow_%d", i), new PathId(format("path_%d", i)))); } assertEquals(maxMeterId - minMeterId + 1, meterIds.size()); meterIds.forEach(meterId -> assertTrue(meterId.getValue() >= minMeterId && meterId.getValue() <= maxMeterId)); }); }
|
public MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize) { transactionManager = persistenceManager.getTransactionManager(); RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory(); flowMeterRepository = repositoryFactory.createFlowMeterRepository(); this.minMeterId = minMeterId; this.maxMeterId = maxMeterId; this.poolSize = poolSize; }
|
MeterPool { public MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize) { transactionManager = persistenceManager.getTransactionManager(); RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory(); flowMeterRepository = repositoryFactory.createFlowMeterRepository(); this.minMeterId = minMeterId; this.maxMeterId = maxMeterId; this.poolSize = poolSize; } }
|
MeterPool { public MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize) { transactionManager = persistenceManager.getTransactionManager(); RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory(); flowMeterRepository = repositoryFactory.createFlowMeterRepository(); this.minMeterId = minMeterId; this.maxMeterId = maxMeterId; this.poolSize = poolSize; } MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize); }
|
MeterPool { public MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize) { transactionManager = persistenceManager.getTransactionManager(); RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory(); flowMeterRepository = repositoryFactory.createFlowMeterRepository(); this.minMeterId = minMeterId; this.maxMeterId = maxMeterId; this.poolSize = poolSize; } MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize); @TransactionRequired MeterId allocate(SwitchId switchId, String flowId, PathId pathId); void deallocate(PathId... pathIds); }
|
MeterPool { public MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize) { transactionManager = persistenceManager.getTransactionManager(); RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory(); flowMeterRepository = repositoryFactory.createFlowMeterRepository(); this.minMeterId = minMeterId; this.maxMeterId = maxMeterId; this.poolSize = poolSize; } MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize); @TransactionRequired MeterId allocate(SwitchId switchId, String flowId, PathId pathId); void deallocate(PathId... pathIds); }
|
@Test(expected = ResourceNotAvailableException.class) public void meterPoolFullTest() { transactionManager.doInTransaction(() -> { for (long i = MIN_METER_ID.getValue(); i <= MAX_METER_ID.getValue() + 1; i++) { meterPool.allocate(SWITCH_ID, format("flow_%d", i), new PathId(format("path_%d", i))); } }); }
|
@TransactionRequired public MeterId allocate(SwitchId switchId, String flowId, PathId pathId) { MeterId nextMeter = nextMeters.get(switchId); if (nextMeter != null && nextMeter.getValue() > 0) { if (nextMeter.compareTo(maxMeterId) <= 0 && !flowMeterRepository.exists(switchId, nextMeter)) { addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } else { nextMeters.remove(switchId); } } if (!nextMeters.containsKey(switchId)) { long numOfPools = (maxMeterId.getValue() - minMeterId.getValue()) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, new MeterId(minMeterId.getValue() + poolToTake * poolSize), new MeterId(minMeterId.getValue() + (poolToTake + 1) * poolSize - 1)); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } nextMeter = new MeterId(-1); nextMeters.put(switchId, nextMeter); } if (nextMeter != null && nextMeter.getValue() == -1) { Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, minMeterId, maxMeterId); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } throw new ResourceNotAvailableException(format("No meter available for switch %s", switchId)); }
|
MeterPool { @TransactionRequired public MeterId allocate(SwitchId switchId, String flowId, PathId pathId) { MeterId nextMeter = nextMeters.get(switchId); if (nextMeter != null && nextMeter.getValue() > 0) { if (nextMeter.compareTo(maxMeterId) <= 0 && !flowMeterRepository.exists(switchId, nextMeter)) { addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } else { nextMeters.remove(switchId); } } if (!nextMeters.containsKey(switchId)) { long numOfPools = (maxMeterId.getValue() - minMeterId.getValue()) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, new MeterId(minMeterId.getValue() + poolToTake * poolSize), new MeterId(minMeterId.getValue() + (poolToTake + 1) * poolSize - 1)); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } nextMeter = new MeterId(-1); nextMeters.put(switchId, nextMeter); } if (nextMeter != null && nextMeter.getValue() == -1) { Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, minMeterId, maxMeterId); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } throw new ResourceNotAvailableException(format("No meter available for switch %s", switchId)); } }
|
MeterPool { @TransactionRequired public MeterId allocate(SwitchId switchId, String flowId, PathId pathId) { MeterId nextMeter = nextMeters.get(switchId); if (nextMeter != null && nextMeter.getValue() > 0) { if (nextMeter.compareTo(maxMeterId) <= 0 && !flowMeterRepository.exists(switchId, nextMeter)) { addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } else { nextMeters.remove(switchId); } } if (!nextMeters.containsKey(switchId)) { long numOfPools = (maxMeterId.getValue() - minMeterId.getValue()) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, new MeterId(minMeterId.getValue() + poolToTake * poolSize), new MeterId(minMeterId.getValue() + (poolToTake + 1) * poolSize - 1)); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } nextMeter = new MeterId(-1); nextMeters.put(switchId, nextMeter); } if (nextMeter != null && nextMeter.getValue() == -1) { Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, minMeterId, maxMeterId); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } throw new ResourceNotAvailableException(format("No meter available for switch %s", switchId)); } MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize); }
|
MeterPool { @TransactionRequired public MeterId allocate(SwitchId switchId, String flowId, PathId pathId) { MeterId nextMeter = nextMeters.get(switchId); if (nextMeter != null && nextMeter.getValue() > 0) { if (nextMeter.compareTo(maxMeterId) <= 0 && !flowMeterRepository.exists(switchId, nextMeter)) { addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } else { nextMeters.remove(switchId); } } if (!nextMeters.containsKey(switchId)) { long numOfPools = (maxMeterId.getValue() - minMeterId.getValue()) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, new MeterId(minMeterId.getValue() + poolToTake * poolSize), new MeterId(minMeterId.getValue() + (poolToTake + 1) * poolSize - 1)); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } nextMeter = new MeterId(-1); nextMeters.put(switchId, nextMeter); } if (nextMeter != null && nextMeter.getValue() == -1) { Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, minMeterId, maxMeterId); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } throw new ResourceNotAvailableException(format("No meter available for switch %s", switchId)); } MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize); @TransactionRequired MeterId allocate(SwitchId switchId, String flowId, PathId pathId); void deallocate(PathId... pathIds); }
|
MeterPool { @TransactionRequired public MeterId allocate(SwitchId switchId, String flowId, PathId pathId) { MeterId nextMeter = nextMeters.get(switchId); if (nextMeter != null && nextMeter.getValue() > 0) { if (nextMeter.compareTo(maxMeterId) <= 0 && !flowMeterRepository.exists(switchId, nextMeter)) { addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } else { nextMeters.remove(switchId); } } if (!nextMeters.containsKey(switchId)) { long numOfPools = (maxMeterId.getValue() - minMeterId.getValue()) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, new MeterId(minMeterId.getValue() + poolToTake * poolSize), new MeterId(minMeterId.getValue() + (poolToTake + 1) * poolSize - 1)); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } nextMeter = new MeterId(-1); nextMeters.put(switchId, nextMeter); } if (nextMeter != null && nextMeter.getValue() == -1) { Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, minMeterId, maxMeterId); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } throw new ResourceNotAvailableException(format("No meter available for switch %s", switchId)); } MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize); @TransactionRequired MeterId allocate(SwitchId switchId, String flowId, PathId pathId); void deallocate(PathId... pathIds); }
|
@Ignore("InMemoryGraph doesn't enforce constraint") @Test(expected = ConstraintViolationException.class) public void createTwoMeterForOnePathTest() { transactionManager.doInTransaction(() -> { long first = meterPool.allocate(SWITCH_ID, FLOW_1, PATH_ID_1).getValue(); long second = meterPool.allocate(SWITCH_ID, FLOW_1, PATH_ID_1).getValue(); }); }
|
@TransactionRequired public MeterId allocate(SwitchId switchId, String flowId, PathId pathId) { MeterId nextMeter = nextMeters.get(switchId); if (nextMeter != null && nextMeter.getValue() > 0) { if (nextMeter.compareTo(maxMeterId) <= 0 && !flowMeterRepository.exists(switchId, nextMeter)) { addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } else { nextMeters.remove(switchId); } } if (!nextMeters.containsKey(switchId)) { long numOfPools = (maxMeterId.getValue() - minMeterId.getValue()) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, new MeterId(minMeterId.getValue() + poolToTake * poolSize), new MeterId(minMeterId.getValue() + (poolToTake + 1) * poolSize - 1)); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } nextMeter = new MeterId(-1); nextMeters.put(switchId, nextMeter); } if (nextMeter != null && nextMeter.getValue() == -1) { Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, minMeterId, maxMeterId); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } throw new ResourceNotAvailableException(format("No meter available for switch %s", switchId)); }
|
MeterPool { @TransactionRequired public MeterId allocate(SwitchId switchId, String flowId, PathId pathId) { MeterId nextMeter = nextMeters.get(switchId); if (nextMeter != null && nextMeter.getValue() > 0) { if (nextMeter.compareTo(maxMeterId) <= 0 && !flowMeterRepository.exists(switchId, nextMeter)) { addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } else { nextMeters.remove(switchId); } } if (!nextMeters.containsKey(switchId)) { long numOfPools = (maxMeterId.getValue() - minMeterId.getValue()) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, new MeterId(minMeterId.getValue() + poolToTake * poolSize), new MeterId(minMeterId.getValue() + (poolToTake + 1) * poolSize - 1)); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } nextMeter = new MeterId(-1); nextMeters.put(switchId, nextMeter); } if (nextMeter != null && nextMeter.getValue() == -1) { Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, minMeterId, maxMeterId); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } throw new ResourceNotAvailableException(format("No meter available for switch %s", switchId)); } }
|
MeterPool { @TransactionRequired public MeterId allocate(SwitchId switchId, String flowId, PathId pathId) { MeterId nextMeter = nextMeters.get(switchId); if (nextMeter != null && nextMeter.getValue() > 0) { if (nextMeter.compareTo(maxMeterId) <= 0 && !flowMeterRepository.exists(switchId, nextMeter)) { addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } else { nextMeters.remove(switchId); } } if (!nextMeters.containsKey(switchId)) { long numOfPools = (maxMeterId.getValue() - minMeterId.getValue()) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, new MeterId(minMeterId.getValue() + poolToTake * poolSize), new MeterId(minMeterId.getValue() + (poolToTake + 1) * poolSize - 1)); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } nextMeter = new MeterId(-1); nextMeters.put(switchId, nextMeter); } if (nextMeter != null && nextMeter.getValue() == -1) { Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, minMeterId, maxMeterId); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } throw new ResourceNotAvailableException(format("No meter available for switch %s", switchId)); } MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize); }
|
MeterPool { @TransactionRequired public MeterId allocate(SwitchId switchId, String flowId, PathId pathId) { MeterId nextMeter = nextMeters.get(switchId); if (nextMeter != null && nextMeter.getValue() > 0) { if (nextMeter.compareTo(maxMeterId) <= 0 && !flowMeterRepository.exists(switchId, nextMeter)) { addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } else { nextMeters.remove(switchId); } } if (!nextMeters.containsKey(switchId)) { long numOfPools = (maxMeterId.getValue() - minMeterId.getValue()) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, new MeterId(minMeterId.getValue() + poolToTake * poolSize), new MeterId(minMeterId.getValue() + (poolToTake + 1) * poolSize - 1)); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } nextMeter = new MeterId(-1); nextMeters.put(switchId, nextMeter); } if (nextMeter != null && nextMeter.getValue() == -1) { Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, minMeterId, maxMeterId); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } throw new ResourceNotAvailableException(format("No meter available for switch %s", switchId)); } MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize); @TransactionRequired MeterId allocate(SwitchId switchId, String flowId, PathId pathId); void deallocate(PathId... pathIds); }
|
MeterPool { @TransactionRequired public MeterId allocate(SwitchId switchId, String flowId, PathId pathId) { MeterId nextMeter = nextMeters.get(switchId); if (nextMeter != null && nextMeter.getValue() > 0) { if (nextMeter.compareTo(maxMeterId) <= 0 && !flowMeterRepository.exists(switchId, nextMeter)) { addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } else { nextMeters.remove(switchId); } } if (!nextMeters.containsKey(switchId)) { long numOfPools = (maxMeterId.getValue() - minMeterId.getValue()) / poolSize; if (numOfPools > 1) { long poolToTake = Math.abs(new Random().nextInt()) % numOfPools; Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, new MeterId(minMeterId.getValue() + poolToTake * poolSize), new MeterId(minMeterId.getValue() + (poolToTake + 1) * poolSize - 1)); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } nextMeter = new MeterId(-1); nextMeters.put(switchId, nextMeter); } if (nextMeter != null && nextMeter.getValue() == -1) { Optional<MeterId> availableMeter = flowMeterRepository.findFirstUnassignedMeter(switchId, minMeterId, maxMeterId); if (availableMeter.isPresent()) { nextMeter = availableMeter.get(); addMeter(flowId, pathId, switchId, nextMeter); nextMeters.put(switchId, new MeterId(nextMeter.getValue() + 1)); return nextMeter; } } throw new ResourceNotAvailableException(format("No meter available for switch %s", switchId)); } MeterPool(PersistenceManager persistenceManager, MeterId minMeterId, MeterId maxMeterId, int poolSize); @TransactionRequired MeterId allocate(SwitchId switchId, String flowId, PathId pathId); void deallocate(PathId... pathIds); }
|
@Test public void shouldReturnTrueWhenSelfLooped() { final SwitchId switchId = new SwitchId("00:00:00:00:00:00:00:01"); PathNode source = new PathNode(switchId, 1, 0); PathNode destination = new PathNode(switchId, 2, 1); IslInfoData isl = new IslInfoData(source, destination, IslChangeType.DISCOVERED, false); assertTrue(isl.isSelfLooped()); }
|
@JsonIgnore public boolean isSelfLooped() { return Objects.equals(source.getSwitchId(), destination.getSwitchId()); }
|
IslInfoData extends CacheTimeTag { @JsonIgnore public boolean isSelfLooped() { return Objects.equals(source.getSwitchId(), destination.getSwitchId()); } }
|
IslInfoData extends CacheTimeTag { @JsonIgnore public boolean isSelfLooped() { return Objects.equals(source.getSwitchId(), destination.getSwitchId()); } IslInfoData(IslInfoData that); IslInfoData(PathNode source, PathNode destination, IslChangeType state, boolean underMaintenance); @Builder(toBuilder = true) @JsonCreator IslInfoData(@JsonProperty("latency_ns") long latency,
@JsonProperty("source") PathNode source,
@JsonProperty("destination") PathNode destination,
@JsonProperty("speed") long speed,
@JsonProperty("available_bandwidth") long availableBandwidth,
@JsonProperty("max_bandwidth") long maxBandwidth,
@JsonProperty("default_max_bandwidth") long defaultMaxBandwidth,
@JsonProperty("state") IslChangeType state,
@JsonProperty("actual_state") IslChangeType actualState,
@JsonProperty("cost") int cost,
@JsonProperty("time_create") Long timeCreateMillis,
@JsonProperty("time_modify") Long timeModifyMillis,
@JsonProperty("under_maintenance") boolean underMaintenance,
@JsonProperty("enable_bfd") boolean enableBfd,
@JsonProperty("bfd_session_status") String bfdSessionStatus,
@JsonProperty("packet_id") Long packetId); }
|
IslInfoData extends CacheTimeTag { @JsonIgnore public boolean isSelfLooped() { return Objects.equals(source.getSwitchId(), destination.getSwitchId()); } IslInfoData(IslInfoData that); IslInfoData(PathNode source, PathNode destination, IslChangeType state, boolean underMaintenance); @Builder(toBuilder = true) @JsonCreator IslInfoData(@JsonProperty("latency_ns") long latency,
@JsonProperty("source") PathNode source,
@JsonProperty("destination") PathNode destination,
@JsonProperty("speed") long speed,
@JsonProperty("available_bandwidth") long availableBandwidth,
@JsonProperty("max_bandwidth") long maxBandwidth,
@JsonProperty("default_max_bandwidth") long defaultMaxBandwidth,
@JsonProperty("state") IslChangeType state,
@JsonProperty("actual_state") IslChangeType actualState,
@JsonProperty("cost") int cost,
@JsonProperty("time_create") Long timeCreateMillis,
@JsonProperty("time_modify") Long timeModifyMillis,
@JsonProperty("under_maintenance") boolean underMaintenance,
@JsonProperty("enable_bfd") boolean enableBfd,
@JsonProperty("bfd_session_status") String bfdSessionStatus,
@JsonProperty("packet_id") Long packetId); void setAvailableBandwidth(long availableBandwidth); void setState(IslChangeType state); @JsonIgnore boolean isSelfLooped(); }
|
IslInfoData extends CacheTimeTag { @JsonIgnore public boolean isSelfLooped() { return Objects.equals(source.getSwitchId(), destination.getSwitchId()); } IslInfoData(IslInfoData that); IslInfoData(PathNode source, PathNode destination, IslChangeType state, boolean underMaintenance); @Builder(toBuilder = true) @JsonCreator IslInfoData(@JsonProperty("latency_ns") long latency,
@JsonProperty("source") PathNode source,
@JsonProperty("destination") PathNode destination,
@JsonProperty("speed") long speed,
@JsonProperty("available_bandwidth") long availableBandwidth,
@JsonProperty("max_bandwidth") long maxBandwidth,
@JsonProperty("default_max_bandwidth") long defaultMaxBandwidth,
@JsonProperty("state") IslChangeType state,
@JsonProperty("actual_state") IslChangeType actualState,
@JsonProperty("cost") int cost,
@JsonProperty("time_create") Long timeCreateMillis,
@JsonProperty("time_modify") Long timeModifyMillis,
@JsonProperty("under_maintenance") boolean underMaintenance,
@JsonProperty("enable_bfd") boolean enableBfd,
@JsonProperty("bfd_session_status") String bfdSessionStatus,
@JsonProperty("packet_id") Long packetId); void setAvailableBandwidth(long availableBandwidth); void setState(IslChangeType state); @JsonIgnore boolean isSelfLooped(); }
|
@Test public void shouldReturnFalseWhenNotSelfLooped() { final SwitchId srcSwitch = new SwitchId("00:00:00:00:00:00:00:01"); final SwitchId dstSwitch = new SwitchId("00:00:00:00:00:00:00:02"); PathNode source = new PathNode(srcSwitch, 1, 0); PathNode destination = new PathNode(dstSwitch, 2, 1); IslInfoData isl = new IslInfoData(source, destination, IslChangeType.DISCOVERED, false); assertFalse(isl.isSelfLooped()); }
|
@JsonIgnore public boolean isSelfLooped() { return Objects.equals(source.getSwitchId(), destination.getSwitchId()); }
|
IslInfoData extends CacheTimeTag { @JsonIgnore public boolean isSelfLooped() { return Objects.equals(source.getSwitchId(), destination.getSwitchId()); } }
|
IslInfoData extends CacheTimeTag { @JsonIgnore public boolean isSelfLooped() { return Objects.equals(source.getSwitchId(), destination.getSwitchId()); } IslInfoData(IslInfoData that); IslInfoData(PathNode source, PathNode destination, IslChangeType state, boolean underMaintenance); @Builder(toBuilder = true) @JsonCreator IslInfoData(@JsonProperty("latency_ns") long latency,
@JsonProperty("source") PathNode source,
@JsonProperty("destination") PathNode destination,
@JsonProperty("speed") long speed,
@JsonProperty("available_bandwidth") long availableBandwidth,
@JsonProperty("max_bandwidth") long maxBandwidth,
@JsonProperty("default_max_bandwidth") long defaultMaxBandwidth,
@JsonProperty("state") IslChangeType state,
@JsonProperty("actual_state") IslChangeType actualState,
@JsonProperty("cost") int cost,
@JsonProperty("time_create") Long timeCreateMillis,
@JsonProperty("time_modify") Long timeModifyMillis,
@JsonProperty("under_maintenance") boolean underMaintenance,
@JsonProperty("enable_bfd") boolean enableBfd,
@JsonProperty("bfd_session_status") String bfdSessionStatus,
@JsonProperty("packet_id") Long packetId); }
|
IslInfoData extends CacheTimeTag { @JsonIgnore public boolean isSelfLooped() { return Objects.equals(source.getSwitchId(), destination.getSwitchId()); } IslInfoData(IslInfoData that); IslInfoData(PathNode source, PathNode destination, IslChangeType state, boolean underMaintenance); @Builder(toBuilder = true) @JsonCreator IslInfoData(@JsonProperty("latency_ns") long latency,
@JsonProperty("source") PathNode source,
@JsonProperty("destination") PathNode destination,
@JsonProperty("speed") long speed,
@JsonProperty("available_bandwidth") long availableBandwidth,
@JsonProperty("max_bandwidth") long maxBandwidth,
@JsonProperty("default_max_bandwidth") long defaultMaxBandwidth,
@JsonProperty("state") IslChangeType state,
@JsonProperty("actual_state") IslChangeType actualState,
@JsonProperty("cost") int cost,
@JsonProperty("time_create") Long timeCreateMillis,
@JsonProperty("time_modify") Long timeModifyMillis,
@JsonProperty("under_maintenance") boolean underMaintenance,
@JsonProperty("enable_bfd") boolean enableBfd,
@JsonProperty("bfd_session_status") String bfdSessionStatus,
@JsonProperty("packet_id") Long packetId); void setAvailableBandwidth(long availableBandwidth); void setState(IslChangeType state); @JsonIgnore boolean isSelfLooped(); }
|
IslInfoData extends CacheTimeTag { @JsonIgnore public boolean isSelfLooped() { return Objects.equals(source.getSwitchId(), destination.getSwitchId()); } IslInfoData(IslInfoData that); IslInfoData(PathNode source, PathNode destination, IslChangeType state, boolean underMaintenance); @Builder(toBuilder = true) @JsonCreator IslInfoData(@JsonProperty("latency_ns") long latency,
@JsonProperty("source") PathNode source,
@JsonProperty("destination") PathNode destination,
@JsonProperty("speed") long speed,
@JsonProperty("available_bandwidth") long availableBandwidth,
@JsonProperty("max_bandwidth") long maxBandwidth,
@JsonProperty("default_max_bandwidth") long defaultMaxBandwidth,
@JsonProperty("state") IslChangeType state,
@JsonProperty("actual_state") IslChangeType actualState,
@JsonProperty("cost") int cost,
@JsonProperty("time_create") Long timeCreateMillis,
@JsonProperty("time_modify") Long timeModifyMillis,
@JsonProperty("under_maintenance") boolean underMaintenance,
@JsonProperty("enable_bfd") boolean enableBfd,
@JsonProperty("bfd_session_status") String bfdSessionStatus,
@JsonProperty("packet_id") Long packetId); void setAvailableBandwidth(long availableBandwidth); void setState(IslChangeType state); @JsonIgnore boolean isSelfLooped(); }
|
@Test public void testNoviflowTimstampToLong() { long seconds = 123456789; long nanoseconds = 987654321; long timestampNovi = (seconds << 32) + nanoseconds; assertEquals(123456789_987654321L, noviflowTimestamp(timestampNovi)); }
|
@VisibleForTesting static long noviflowTimestamp(Long v) { long seconds = (v >> 32); long nanoseconds = (v & 0xFFFFFFFFL); return seconds * TEN_TO_NINE + nanoseconds; }
|
FlowRttMetricGenBolt extends MetricGenBolt { @VisibleForTesting static long noviflowTimestamp(Long v) { long seconds = (v >> 32); long nanoseconds = (v & 0xFFFFFFFFL); return seconds * TEN_TO_NINE + nanoseconds; } }
|
FlowRttMetricGenBolt extends MetricGenBolt { @VisibleForTesting static long noviflowTimestamp(Long v) { long seconds = (v >> 32); long nanoseconds = (v & 0xFFFFFFFFL); return seconds * TEN_TO_NINE + nanoseconds; } FlowRttMetricGenBolt(String metricPrefix); }
|
FlowRttMetricGenBolt extends MetricGenBolt { @VisibleForTesting static long noviflowTimestamp(Long v) { long seconds = (v >> 32); long nanoseconds = (v & 0xFFFFFFFFL); return seconds * TEN_TO_NINE + nanoseconds; } FlowRttMetricGenBolt(String metricPrefix); }
|
FlowRttMetricGenBolt extends MetricGenBolt { @VisibleForTesting static long noviflowTimestamp(Long v) { long seconds = (v >> 32); long nanoseconds = (v & 0xFFFFFFFFL); return seconds * TEN_TO_NINE + nanoseconds; } FlowRttMetricGenBolt(String metricPrefix); static final long TEN_TO_NINE; }
|
@Test public void mapFlowToFlowRequestTest() { FlowRequest flowRequest = RequestedFlowMapper.INSTANCE.toFlowRequest(flow); assertEquals(FLOW_ID, flowRequest.getFlowId()); assertEquals(SRC_SWITCH_ID, flowRequest.getSource().getSwitchId()); assertEquals(SRC_PORT, flowRequest.getSource().getPortNumber()); assertEquals(SRC_VLAN, flowRequest.getSource().getOuterVlanId()); assertEquals(DST_SWITCH_ID, flowRequest.getDestination().getSwitchId()); assertEquals(DST_PORT, flowRequest.getDestination().getPortNumber()); assertEquals(DST_VLAN, flowRequest.getDestination().getOuterVlanId()); assertEquals(PRIORITY, flowRequest.getPriority()); assertEquals(DESCRIPTION, flowRequest.getDescription()); assertEquals(BANDWIDTH, flowRequest.getBandwidth()); assertEquals(MAX_LATENCY, flowRequest.getMaxLatency()); assertEquals(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN, flowRequest.getEncapsulationType()); assertEquals(PATH_COMPUTATION_STRATEGY, flowRequest.getPathComputationStrategy()); assertTrue(flowRequest.isPinned()); assertTrue(flowRequest.isAllocateProtectedPath()); assertTrue(flowRequest.isIgnoreBandwidth()); assertTrue(flowRequest.isPeriodicPings()); assertEquals(new DetectConnectedDevicesDto(true, true, true, true, true, true, true, true), flowRequest.getDetectConnectedDevices()); }
|
@Mapping(target = "flowId", source = "flowId") @Mapping(target = "source", expression = "java(new FlowEndpoint(flow.getSrcSwitchId(), " + "flow.getSrcPort(), flow.getSrcVlan()))") @Mapping(target = "destination", expression = "java(new FlowEndpoint(flow.getDestSwitchId(), " + "flow.getDestPort(), flow.getDestVlan()))") @Mapping(target = "encapsulationType", source = "encapsulationType") @Mapping(target = "pathComputationStrategy", expression = "java(java.util.Optional.ofNullable(flow.getPathComputationStrategy())" + ".map(pcs -> pcs.toString().toLowerCase())" + ".orElse(null))") @Mapping(target = "bandwidth", source = "bandwidth") @Mapping(target = "ignoreBandwidth", source = "ignoreBandwidth") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "description", source = "description") @Mapping(target = "maxLatency", source = "maxLatency") @Mapping(target = "priority", source = "priority") @Mapping(target = "pinned", source = "pinned") @Mapping(target = "detectConnectedDevices", source = "detectConnectedDevices") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) public abstract FlowRequest toFlowRequest(Flow flow);
|
RequestedFlowMapper { @Mapping(target = "flowId", source = "flowId") @Mapping(target = "source", expression = "java(new FlowEndpoint(flow.getSrcSwitchId(), " + "flow.getSrcPort(), flow.getSrcVlan()))") @Mapping(target = "destination", expression = "java(new FlowEndpoint(flow.getDestSwitchId(), " + "flow.getDestPort(), flow.getDestVlan()))") @Mapping(target = "encapsulationType", source = "encapsulationType") @Mapping(target = "pathComputationStrategy", expression = "java(java.util.Optional.ofNullable(flow.getPathComputationStrategy())" + ".map(pcs -> pcs.toString().toLowerCase())" + ".orElse(null))") @Mapping(target = "bandwidth", source = "bandwidth") @Mapping(target = "ignoreBandwidth", source = "ignoreBandwidth") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "description", source = "description") @Mapping(target = "maxLatency", source = "maxLatency") @Mapping(target = "priority", source = "priority") @Mapping(target = "pinned", source = "pinned") @Mapping(target = "detectConnectedDevices", source = "detectConnectedDevices") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) public abstract FlowRequest toFlowRequest(Flow flow); }
|
RequestedFlowMapper { @Mapping(target = "flowId", source = "flowId") @Mapping(target = "source", expression = "java(new FlowEndpoint(flow.getSrcSwitchId(), " + "flow.getSrcPort(), flow.getSrcVlan()))") @Mapping(target = "destination", expression = "java(new FlowEndpoint(flow.getDestSwitchId(), " + "flow.getDestPort(), flow.getDestVlan()))") @Mapping(target = "encapsulationType", source = "encapsulationType") @Mapping(target = "pathComputationStrategy", expression = "java(java.util.Optional.ofNullable(flow.getPathComputationStrategy())" + ".map(pcs -> pcs.toString().toLowerCase())" + ".orElse(null))") @Mapping(target = "bandwidth", source = "bandwidth") @Mapping(target = "ignoreBandwidth", source = "ignoreBandwidth") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "description", source = "description") @Mapping(target = "maxLatency", source = "maxLatency") @Mapping(target = "priority", source = "priority") @Mapping(target = "pinned", source = "pinned") @Mapping(target = "detectConnectedDevices", source = "detectConnectedDevices") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) public abstract FlowRequest toFlowRequest(Flow flow); }
|
RequestedFlowMapper { @Mapping(target = "flowId", source = "flowId") @Mapping(target = "source", expression = "java(new FlowEndpoint(flow.getSrcSwitchId(), " + "flow.getSrcPort(), flow.getSrcVlan()))") @Mapping(target = "destination", expression = "java(new FlowEndpoint(flow.getDestSwitchId(), " + "flow.getDestPort(), flow.getDestVlan()))") @Mapping(target = "encapsulationType", source = "encapsulationType") @Mapping(target = "pathComputationStrategy", expression = "java(java.util.Optional.ofNullable(flow.getPathComputationStrategy())" + ".map(pcs -> pcs.toString().toLowerCase())" + ".orElse(null))") @Mapping(target = "bandwidth", source = "bandwidth") @Mapping(target = "ignoreBandwidth", source = "ignoreBandwidth") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "description", source = "description") @Mapping(target = "maxLatency", source = "maxLatency") @Mapping(target = "priority", source = "priority") @Mapping(target = "pinned", source = "pinned") @Mapping(target = "detectConnectedDevices", source = "detectConnectedDevices") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) public abstract FlowRequest toFlowRequest(Flow flow); @Mapping(target = "flowId", source = "flowId") @Mapping(target = "source", expression = "java(new FlowEndpoint(flow.getSrcSwitchId(), " + "flow.getSrcPort(), flow.getSrcVlan()))") @Mapping(target = "destination", expression = "java(new FlowEndpoint(flow.getDestSwitchId(), " + "flow.getDestPort(), flow.getDestVlan()))") @Mapping(target = "encapsulationType", source = "encapsulationType") @Mapping(target = "pathComputationStrategy", expression = "java(java.util.Optional.ofNullable(flow.getPathComputationStrategy())" + ".map(pcs -> pcs.toString().toLowerCase())" + ".orElse(null))") @Mapping(target = "bandwidth", source = "bandwidth") @Mapping(target = "ignoreBandwidth", source = "ignoreBandwidth") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "description", source = "description") @Mapping(target = "maxLatency", source = "maxLatency") @Mapping(target = "priority", source = "priority") @Mapping(target = "pinned", source = "pinned") @Mapping(target = "detectConnectedDevices", source = "detectConnectedDevices") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) abstract FlowRequest toFlowRequest(Flow flow); }
|
RequestedFlowMapper { @Mapping(target = "flowId", source = "flowId") @Mapping(target = "source", expression = "java(new FlowEndpoint(flow.getSrcSwitchId(), " + "flow.getSrcPort(), flow.getSrcVlan()))") @Mapping(target = "destination", expression = "java(new FlowEndpoint(flow.getDestSwitchId(), " + "flow.getDestPort(), flow.getDestVlan()))") @Mapping(target = "encapsulationType", source = "encapsulationType") @Mapping(target = "pathComputationStrategy", expression = "java(java.util.Optional.ofNullable(flow.getPathComputationStrategy())" + ".map(pcs -> pcs.toString().toLowerCase())" + ".orElse(null))") @Mapping(target = "bandwidth", source = "bandwidth") @Mapping(target = "ignoreBandwidth", source = "ignoreBandwidth") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "description", source = "description") @Mapping(target = "maxLatency", source = "maxLatency") @Mapping(target = "priority", source = "priority") @Mapping(target = "pinned", source = "pinned") @Mapping(target = "detectConnectedDevices", source = "detectConnectedDevices") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) public abstract FlowRequest toFlowRequest(Flow flow); @Mapping(target = "flowId", source = "flowId") @Mapping(target = "source", expression = "java(new FlowEndpoint(flow.getSrcSwitchId(), " + "flow.getSrcPort(), flow.getSrcVlan()))") @Mapping(target = "destination", expression = "java(new FlowEndpoint(flow.getDestSwitchId(), " + "flow.getDestPort(), flow.getDestVlan()))") @Mapping(target = "encapsulationType", source = "encapsulationType") @Mapping(target = "pathComputationStrategy", expression = "java(java.util.Optional.ofNullable(flow.getPathComputationStrategy())" + ".map(pcs -> pcs.toString().toLowerCase())" + ".orElse(null))") @Mapping(target = "bandwidth", source = "bandwidth") @Mapping(target = "ignoreBandwidth", source = "ignoreBandwidth") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "description", source = "description") @Mapping(target = "maxLatency", source = "maxLatency") @Mapping(target = "priority", source = "priority") @Mapping(target = "pinned", source = "pinned") @Mapping(target = "detectConnectedDevices", source = "detectConnectedDevices") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) abstract FlowRequest toFlowRequest(Flow flow); static final RequestedFlowMapper INSTANCE; }
|
@Test public void findDirectionTest() throws Exception { assertEquals(Direction.FORWARD, FlowDirectionHelper.findDirection(FORWARD_COOKIE)); assertEquals(Direction.REVERSE, FlowDirectionHelper.findDirection(REVERSE_COOKIE)); thrown.expect(FlowCookieException.class); FlowDirectionHelper.findDirection(BAD_COOKIE); }
|
public static Direction findDirection(long rawCookie) throws FlowCookieException { return findDirectionSafe(rawCookie) .orElseThrow(() -> new FlowCookieException(String.format( "unknown direction for %s", new Cookie(rawCookie)))); }
|
FlowDirectionHelper { public static Direction findDirection(long rawCookie) throws FlowCookieException { return findDirectionSafe(rawCookie) .orElseThrow(() -> new FlowCookieException(String.format( "unknown direction for %s", new Cookie(rawCookie)))); } }
|
FlowDirectionHelper { public static Direction findDirection(long rawCookie) throws FlowCookieException { return findDirectionSafe(rawCookie) .orElseThrow(() -> new FlowCookieException(String.format( "unknown direction for %s", new Cookie(rawCookie)))); } private FlowDirectionHelper(); }
|
FlowDirectionHelper { public static Direction findDirection(long rawCookie) throws FlowCookieException { return findDirectionSafe(rawCookie) .orElseThrow(() -> new FlowCookieException(String.format( "unknown direction for %s", new Cookie(rawCookie)))); } private FlowDirectionHelper(); static Direction findDirection(long rawCookie); static Optional<Direction> findDirectionSafe(long rawCookie); }
|
FlowDirectionHelper { public static Direction findDirection(long rawCookie) throws FlowCookieException { return findDirectionSafe(rawCookie) .orElseThrow(() -> new FlowCookieException(String.format( "unknown direction for %s", new Cookie(rawCookie)))); } private FlowDirectionHelper(); static Direction findDirection(long rawCookie); static Optional<Direction> findDirectionSafe(long rawCookie); }
|
@Test @WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE) public void createFlow() throws Exception { MvcResult mvcResult = mockMvc.perform(put("/v1/flows") .header(CORRELATION_ID, testCorrelationId()) .contentType(APPLICATION_JSON_VALUE) .content(MAPPER.writeValueAsString(TestMessageMock.flow))) .andReturn(); MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)) .andReturn(); System.out.println("RESPONSE: " + result.getResponse().getContentAsString()); FlowPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload.class); assertEquals(TestMessageMock.flow, response); }
|
@ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow) { return flowService.createFlow(flow); }
|
FlowController extends BaseController { @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow) { return flowService.createFlow(flow); } }
|
FlowController extends BaseController { @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow) { return flowService.createFlow(flow); } }
|
FlowController extends BaseController { @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow) { return flowService.createFlow(flow); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
FlowController extends BaseController { @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow) { return flowService.createFlow(flow); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
@Test @WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE) public void getFlow() throws Exception { MvcResult mvcResult = mockMvc.perform(get("/v1/flows/{flow-id}", TestMessageMock.FLOW_ID) .header(CORRELATION_ID, testCorrelationId()) .contentType(APPLICATION_JSON_VALUE)) .andReturn(); MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)) .andReturn(); FlowPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload.class); assertEquals(TestMessageMock.flow, response); }
|
@ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.getFlow(flowId); }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.getFlow(flowId); } }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.getFlow(flowId); } }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.getFlow(flowId); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.getFlow(flowId); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
@Test @WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE) public void deleteFlow() throws Exception { MvcResult mvcResult = mockMvc.perform(delete("/v1/flows/{flow-id}", TestMessageMock.FLOW_ID) .header(CORRELATION_ID, testCorrelationId()) .contentType(APPLICATION_JSON_VALUE)) .andReturn(); MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)) .andReturn(); FlowPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload.class); assertEquals(TestMessageMock.flow, response); }
|
@ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.deleteFlow(flowId); }
|
FlowController extends BaseController { @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.deleteFlow(flowId); } }
|
FlowController extends BaseController { @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.deleteFlow(flowId); } }
|
FlowController extends BaseController { @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.deleteFlow(flowId); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
FlowController extends BaseController { @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.deleteFlow(flowId); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
@Test @WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE) public void deleteFlows() throws Exception { MvcResult mvcResult = mockMvc.perform(delete("/v1/flows") .header(CORRELATION_ID, testCorrelationId()) .header(EXTRA_AUTH, System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(119)) .contentType(APPLICATION_JSON_VALUE)) .andReturn(); MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)) .andReturn(); FlowPayload[] response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload[].class); assertEquals(TestMessageMock.flow, response[0]); }
|
@ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired public CompletableFuture<List<FlowResponsePayload>> deleteFlows() { return flowService.deleteAllFlows(); }
|
FlowController extends BaseController { @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired public CompletableFuture<List<FlowResponsePayload>> deleteFlows() { return flowService.deleteAllFlows(); } }
|
FlowController extends BaseController { @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired public CompletableFuture<List<FlowResponsePayload>> deleteFlows() { return flowService.deleteAllFlows(); } }
|
FlowController extends BaseController { @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired public CompletableFuture<List<FlowResponsePayload>> deleteFlows() { return flowService.deleteAllFlows(); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
FlowController extends BaseController { @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired public CompletableFuture<List<FlowResponsePayload>> deleteFlows() { return flowService.deleteAllFlows(); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
@Test @WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE) public void updateFlow() throws Exception { MvcResult mvcResult = mockMvc.perform(put("/v1/flows/{flow-id}", TestMessageMock.FLOW_ID) .header(CORRELATION_ID, testCorrelationId()) .contentType(APPLICATION_JSON_VALUE) .content(MAPPER.writeValueAsString(TestMessageMock.flow))) .andReturn(); MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)) .andReturn(); FlowPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload.class); assertEquals(TestMessageMock.flow, response); }
|
@ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId, @RequestBody FlowUpdatePayload flow) { return flowService.updateFlow(flow); }
|
FlowController extends BaseController { @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId, @RequestBody FlowUpdatePayload flow) { return flowService.updateFlow(flow); } }
|
FlowController extends BaseController { @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId, @RequestBody FlowUpdatePayload flow) { return flowService.updateFlow(flow); } }
|
FlowController extends BaseController { @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId, @RequestBody FlowUpdatePayload flow) { return flowService.updateFlow(flow); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
FlowController extends BaseController { @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId, @RequestBody FlowUpdatePayload flow) { return flowService.updateFlow(flow); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
@Test @WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE) public void getFlows() throws Exception { MvcResult mvcResult = mockMvc.perform(get("/v1/flows", TestMessageMock.FLOW_ID) .header(CORRELATION_ID, testCorrelationId()) .contentType(APPLICATION_JSON_VALUE)) .andReturn(); MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)) .andReturn(); List<FlowPayload> response = MAPPER.readValue( result.getResponse().getContentAsString(), new TypeReference<List<FlowPayload>>() {}); assertEquals(Collections.singletonList(TestMessageMock.flow), response); }
|
@ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<List<FlowResponsePayload>> getFlows() { return flowService.getAllFlows(); }
|
FlowController extends BaseController { @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<List<FlowResponsePayload>> getFlows() { return flowService.getAllFlows(); } }
|
FlowController extends BaseController { @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<List<FlowResponsePayload>> getFlows() { return flowService.getAllFlows(); } }
|
FlowController extends BaseController { @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<List<FlowResponsePayload>> getFlows() { return flowService.getAllFlows(); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
FlowController extends BaseController { @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) public CompletableFuture<List<FlowResponsePayload>> getFlows() { return flowService.getAllFlows(); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
@Test @WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE) public void statusFlow() throws Exception { MvcResult mvcResult = mockMvc.perform(get("/v1/flows/status/{flow-id}", TestMessageMock.FLOW_ID) .header(CORRELATION_ID, testCorrelationId()) .contentType(APPLICATION_JSON_VALUE)) .andReturn(); MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)) .andReturn(); FlowIdStatusPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowIdStatusPayload.class); assertEquals(TestMessageMock.flowStatus, response); }
|
@ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.statusFlow(flowId); }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.statusFlow(flowId); } }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.statusFlow(flowId); } }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.statusFlow(flowId); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.statusFlow(flowId); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
@Test @WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE) public void pathFlow() throws Exception { MvcResult mvcResult = mockMvc.perform(get("/v1/flows/{flow-id}/path", TestMessageMock.FLOW_ID) .header(CORRELATION_ID, testCorrelationId()) .contentType(APPLICATION_JSON_VALUE)) .andReturn(); MvcResult result = mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)) .andReturn(); FlowPathPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPathPayload.class); assertEquals(TestMessageMock.flowPath, response); }
|
@ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.pathFlow(flowId); }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.pathFlow(flowId); } }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.pathFlow(flowId); } }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.pathFlow(flowId); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
FlowController extends BaseController { @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) public CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId) { return flowService.pathFlow(flowId); } @ApiOperation(value = "Creates new flow", response = FlowResponsePayload.class) @PutMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> createFlow(@RequestBody FlowCreatePayload flow); @ApiOperation(value = "Gets flow", response = FlowResponsePayload.class) @GetMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> getFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Deletes flow", response = FlowResponsePayload.class) @DeleteMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> deleteFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PutMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> updateFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowUpdatePayload flow); @ApiOperation(value = "Updates flow", response = FlowResponsePayload.class) @PatchMapping(value = "/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> patchFlow(@PathVariable(name = "flow-id") String flowId,
@RequestBody FlowPatchDto flowPatchDto); @ApiOperation(value = "Dumps all flows", response = FlowResponsePayload.class, responseContainer = "List") @GetMapping @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowResponsePayload>> getFlows(); @ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowResponsePayload.class, responseContainer = "List") @DeleteMapping @ResponseStatus(HttpStatus.OK) @ExtraAuthRequired CompletableFuture<List<FlowResponsePayload>> deleteFlows(); @ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class) @GetMapping(value = "/status/{flow-id:.+}") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId); @ApiOperation(value = "Gets flow path", response = FlowPathPayload.class) @GetMapping(value = "/{flow-id}/path") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowPathPayload> pathFlow(@PathVariable(name = "flow-id") String flowId); @Deprecated @ApiOperation(value = "Push flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/push") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> pushFlows(); @Deprecated @ApiOperation(value = "Unpush flows without expectation of modifying switches. It can push to switch and validate.", response = BatchResults.class) @PutMapping(path = "/unpush") @ResponseStatus(HttpStatus.OK) CompletableFuture<BatchResults> unpushFlows(); @ApiOperation(value = "Reroute flow", response = FlowReroutePayload.class) @PatchMapping(path = "/{flow_id}/reroute") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> rerouteFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Swap paths for flow with protected path", response = FlowResponsePayload.class) @PatchMapping(path = "/{flow_id}/swap") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowResponsePayload> swapFlowPaths(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Sync flow", response = FlowReroutePayload.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowReroutePayload.class, message = "Operation is successful")}) @PatchMapping(path = "/{flow_id}/sync") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowReroutePayload> syncFlow(@PathVariable("flow_id") String flowId); @ApiOperation(value = "Validate flow, comparing the DB to each switch", response = FlowValidationDto.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/validate") @ResponseStatus(HttpStatus.OK) CompletableFuture<List<FlowValidationDto>> validateFlow(@PathVariable("flow_id") String flowId); @ApiOperation( value = "Verify flow - using special network packet that is being routed in the same way as client traffic", response = PingOutput.class) @PutMapping(path = "/{flow_id}/ping") @ResponseStatus(HttpStatus.OK) CompletableFuture<PingOutput> pingFlow(
@RequestBody PingInput payload,
@PathVariable("flow_id") String flowId); @ApiOperation(value = "Invalidate (purge) Flow Resources Cache(s)") @DeleteMapping(path = "/cache") @ResponseStatus(HttpStatus.OK) void invalidateFlowCache(); @ApiOperation(value = "Update burst parameter in meter", response = FlowMeterEntries.class) @PatchMapping(path = "/{flow_id}/meters") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowMeterEntries> updateMetersBurst(@PathVariable("flow_id") String flowId); @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ApiOperation(value = "Gets history for flow", response = FlowHistoryEntry.class, responseContainer = "List") @GetMapping(path = "/{flow_id}/history") CompletableFuture<ResponseEntity<List<FlowHistoryEntry>>> getHistory(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "default: 0 (1 January 1970 00:00:00).")
@RequestParam(value = "timeFrom", required = false) Optional<Long> optionalTimeFrom,
@ApiParam(value = "default: now.")
@RequestParam(value = "timeTo", required = false) Optional<Long> optionalTimeTo,
@ApiParam(value = "Return at most N latest records. "
+ "Default: if `timeFrom` or/and `timeTo` parameters are presented default value of "
+ "`maxCount` is infinite (all records in time interval will be returned). "
+ "Otherwise default value of `maxCount` will be equal to 100. In This case response will contain "
+ "header 'Content-Range'.")
@RequestParam(value = "max_count", required = false) Optional<Integer> optionalMaxCount); @ApiOperation(value = "Gets flow connected devices", response = FlowConnectedDevicesResponse.class) @GetMapping(path = "/{flow_id}/devices") @ResponseStatus(HttpStatus.OK) CompletableFuture<FlowConnectedDevicesResponse> getConnectedDevices(
@PathVariable("flow_id") String flowId,
@ApiParam(value = "Device will be included in response if it's `time_last_seen` >= `since`. "
+ "Example of `since` value: `2019-09-30T16:14:12.538Z`",
required = false)
@RequestParam(value = "since", required = false) Optional<String> since); }
|
@Test public void testFlowRequestV2Mapping() { FlowRequestV2 flowRequestV2 = FlowRequestV2.builder() .flowId(FLOW_ID) .encapsulationType(ENCAPSULATION_TYPE) .source(new FlowEndpointV2(SRC_SWITCH_ID, SRC_PORT, SRC_VLAN, SRC_DETECT_CONNECTED_DEVICES)) .destination(new FlowEndpointV2(DST_SWITCH_ID, DST_PORT, DST_VLAN, DST_DETECT_CONNECTED_DEVICES)) .description(DESCRIPTION) .maximumBandwidth(BANDWIDTH) .maxLatency(LATENCY) .priority(PRIORITY) .diverseFlowId(DIVERSE_FLOW_ID) .build(); FlowRequest flowRequest = flowMapper.toFlowRequest(flowRequestV2); assertEquals(FLOW_ID, flowRequest.getFlowId()); assertEquals(SRC_SWITCH_ID, flowRequest.getSource().getSwitchId()); assertEquals(SRC_PORT, (int) flowRequest.getSource().getPortNumber()); assertEquals(SRC_VLAN, flowRequest.getSource().getOuterVlanId()); assertEquals(DST_SWITCH_ID, flowRequest.getDestination().getSwitchId()); assertEquals(DST_PORT, (int) flowRequest.getDestination().getPortNumber()); assertEquals(DST_VLAN, flowRequest.getDestination().getOuterVlanId()); assertEquals(FlowEncapsulationType.TRANSIT_VLAN, flowRequest.getEncapsulationType()); assertEquals(DESCRIPTION, flowRequest.getDescription()); assertEquals(BANDWIDTH, flowRequest.getBandwidth()); assertEquals(LATENCY * 1000000L, (long) flowRequest.getMaxLatency()); assertEquals(PRIORITY, flowRequest.getPriority()); assertEquals(DIVERSE_FLOW_ID, flowRequest.getDiverseFlowId()); assertEquals(SRC_DETECT_CONNECTED_DEVICES.isLldp(), flowRequest.getDetectConnectedDevices().isSrcLldp()); assertEquals(SRC_DETECT_CONNECTED_DEVICES.isArp(), flowRequest.getDetectConnectedDevices().isSrcArp()); assertEquals(DST_DETECT_CONNECTED_DEVICES.isLldp(), flowRequest.getDetectConnectedDevices().isDstLldp()); assertEquals(DST_DETECT_CONNECTED_DEVICES.isArp(), flowRequest.getDetectConnectedDevices().isDstArp()); }
|
@Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request);
|
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request); }
|
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request); }
|
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request); FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request); FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
@Test public void isCookieMismatch0() { OfInput input = makeInput(U64.of(cookieAlpha.getValue())); Assert.assertFalse(input.packetInCookieMismatchAll(callerLogger, cookieAlpha)); }
|
public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } OfInput(IOFSwitch sw, OFMessage message, FloodlightContext context); }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } OfInput(IOFSwitch sw, OFMessage message, FloodlightContext context); U64 packetInCookie(); boolean packetInCookieMismatchAll(Logger log, U64... expected); OFType getType(); long getReceiveTime(); DatapathId getDpId(); OFMessage getMessage(); Long getLatency(); Ethernet getPacketInPayload(); OFPort getPort(); @Override String toString(); }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } OfInput(IOFSwitch sw, OFMessage message, FloodlightContext context); U64 packetInCookie(); boolean packetInCookieMismatchAll(Logger log, U64... expected); OFType getType(); long getReceiveTime(); DatapathId getDpId(); OFMessage getMessage(); Long getLatency(); Ethernet getPacketInPayload(); OFPort getPort(); @Override String toString(); }
|
@Test(expected = IllegalArgumentException.class) public void testFlowRequestV2InvalidEncapsulation() { FlowRequestV2 flowRequestV2 = FlowRequestV2.builder() .flowId(FLOW_ID) .encapsulationType("abc") .source(new FlowEndpointV2(SRC_SWITCH_ID, SRC_PORT, SRC_VLAN, SRC_DETECT_CONNECTED_DEVICES)) .destination(new FlowEndpointV2(DST_SWITCH_ID, DST_PORT, DST_VLAN, DST_DETECT_CONNECTED_DEVICES)) .build(); flowMapper.toFlowRequest(flowRequestV2); }
|
@Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request);
|
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request); }
|
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request); }
|
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request); FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
FlowMapper { @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") public abstract FlowRequest toFlowRequest(FlowRequestV2 request); FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
@Test public void testFlowCreatePayloadToFlowRequest() { FlowRequest flowRequest = flowMapper.toFlowCreateRequest(FLOW_CREATE_PAYLOAD); assertEquals(FLOW_CREATE_PAYLOAD.getDiverseFlowId(), flowRequest.getDiverseFlowId()); assertEquals(Type.CREATE, flowRequest.getType()); assertFlowDtos(FLOW_CREATE_PAYLOAD, flowRequest); }
|
public FlowRequest toFlowCreateRequest(FlowRequestV2 source) { return toFlowRequest(source).toBuilder().type(Type.CREATE).build(); }
|
FlowMapper { public FlowRequest toFlowCreateRequest(FlowRequestV2 source) { return toFlowRequest(source).toBuilder().type(Type.CREATE).build(); } }
|
FlowMapper { public FlowRequest toFlowCreateRequest(FlowRequestV2 source) { return toFlowRequest(source).toBuilder().type(Type.CREATE).build(); } }
|
FlowMapper { public FlowRequest toFlowCreateRequest(FlowRequestV2 source) { return toFlowRequest(source).toBuilder().type(Type.CREATE).build(); } FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
FlowMapper { public FlowRequest toFlowCreateRequest(FlowRequestV2 source) { return toFlowRequest(source).toBuilder().type(Type.CREATE).build(); } FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
@Test public void testFlowUpdatePayloadToFlowRequest() { FlowRequest flowRequest = flowMapper.toFlowUpdateRequest(FLOW_UPDATE_PAYLOAD); assertEquals(FLOW_UPDATE_PAYLOAD.getDiverseFlowId(), flowRequest.getDiverseFlowId()); assertEquals(Type.UPDATE, flowRequest.getType()); assertFlowDtos(FLOW_UPDATE_PAYLOAD, flowRequest); }
|
public FlowRequest toFlowUpdateRequest(FlowUpdatePayload source) { FlowRequest target = toFlowRequest(source).toBuilder() .diverseFlowId(source.getDiverseFlowId()) .type(Type.UPDATE) .build(); if (source.getSource().getDetectConnectedDevices() != null) { DetectConnectedDevicesPayload srcDevs = source.getSource().getDetectConnectedDevices(); target.getDetectConnectedDevices().setSrcArp(srcDevs.isArp()); target.getDetectConnectedDevices().setSrcLldp(srcDevs.isLldp()); } if (source.getDestination().getDetectConnectedDevices() != null) { DetectConnectedDevicesPayload dstDevs = source.getDestination().getDetectConnectedDevices(); target.getDetectConnectedDevices().setDstArp(dstDevs.isArp()); target.getDetectConnectedDevices().setDstLldp(dstDevs.isLldp()); } return target; }
|
FlowMapper { public FlowRequest toFlowUpdateRequest(FlowUpdatePayload source) { FlowRequest target = toFlowRequest(source).toBuilder() .diverseFlowId(source.getDiverseFlowId()) .type(Type.UPDATE) .build(); if (source.getSource().getDetectConnectedDevices() != null) { DetectConnectedDevicesPayload srcDevs = source.getSource().getDetectConnectedDevices(); target.getDetectConnectedDevices().setSrcArp(srcDevs.isArp()); target.getDetectConnectedDevices().setSrcLldp(srcDevs.isLldp()); } if (source.getDestination().getDetectConnectedDevices() != null) { DetectConnectedDevicesPayload dstDevs = source.getDestination().getDetectConnectedDevices(); target.getDetectConnectedDevices().setDstArp(dstDevs.isArp()); target.getDetectConnectedDevices().setDstLldp(dstDevs.isLldp()); } return target; } }
|
FlowMapper { public FlowRequest toFlowUpdateRequest(FlowUpdatePayload source) { FlowRequest target = toFlowRequest(source).toBuilder() .diverseFlowId(source.getDiverseFlowId()) .type(Type.UPDATE) .build(); if (source.getSource().getDetectConnectedDevices() != null) { DetectConnectedDevicesPayload srcDevs = source.getSource().getDetectConnectedDevices(); target.getDetectConnectedDevices().setSrcArp(srcDevs.isArp()); target.getDetectConnectedDevices().setSrcLldp(srcDevs.isLldp()); } if (source.getDestination().getDetectConnectedDevices() != null) { DetectConnectedDevicesPayload dstDevs = source.getDestination().getDetectConnectedDevices(); target.getDetectConnectedDevices().setDstArp(dstDevs.isArp()); target.getDetectConnectedDevices().setDstLldp(dstDevs.isLldp()); } return target; } }
|
FlowMapper { public FlowRequest toFlowUpdateRequest(FlowUpdatePayload source) { FlowRequest target = toFlowRequest(source).toBuilder() .diverseFlowId(source.getDiverseFlowId()) .type(Type.UPDATE) .build(); if (source.getSource().getDetectConnectedDevices() != null) { DetectConnectedDevicesPayload srcDevs = source.getSource().getDetectConnectedDevices(); target.getDetectConnectedDevices().setSrcArp(srcDevs.isArp()); target.getDetectConnectedDevices().setSrcLldp(srcDevs.isLldp()); } if (source.getDestination().getDetectConnectedDevices() != null) { DetectConnectedDevicesPayload dstDevs = source.getDestination().getDetectConnectedDevices(); target.getDetectConnectedDevices().setDstArp(dstDevs.isArp()); target.getDetectConnectedDevices().setDstLldp(dstDevs.isLldp()); } return target; } FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
FlowMapper { public FlowRequest toFlowUpdateRequest(FlowUpdatePayload source) { FlowRequest target = toFlowRequest(source).toBuilder() .diverseFlowId(source.getDiverseFlowId()) .type(Type.UPDATE) .build(); if (source.getSource().getDetectConnectedDevices() != null) { DetectConnectedDevicesPayload srcDevs = source.getSource().getDetectConnectedDevices(); target.getDetectConnectedDevices().setSrcArp(srcDevs.isArp()); target.getDetectConnectedDevices().setSrcLldp(srcDevs.isLldp()); } if (source.getDestination().getDetectConnectedDevices() != null) { DetectConnectedDevicesPayload dstDevs = source.getDestination().getDetectConnectedDevices(); target.getDetectConnectedDevices().setDstArp(dstDevs.isArp()); target.getDetectConnectedDevices().setDstLldp(dstDevs.isLldp()); } return target; } FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
@Test public void testFlowPatchDtoToFlowDto() { FlowPatchDto flowPatchDto = new FlowPatchDto(LATENCY, PRIORITY, PERIODIC_PINGS, TARGET_PATH_COMPUTATION_STRATEGY); FlowPatch flowPatch = flowMapper.toFlowPatch(flowPatchDto); assertEquals(flowPatchDto.getMaxLatency() * 1000000L, (long) flowPatch.getMaxLatency()); assertEquals(flowPatchDto.getPriority(), flowPatch.getPriority()); assertEquals(flowPatchDto.getPeriodicPings(), flowPatch.getPeriodicPings()); assertEquals(flowPatchDto.getTargetPathComputationStrategy(), flowPatch.getTargetPathComputationStrategy().name().toLowerCase()); }
|
@Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto);
|
FlowMapper { @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); }
|
FlowMapper { @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); }
|
FlowMapper { @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
FlowMapper { @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
@Test public void testFlowPatchV2ToFlowDto() { FlowPatchV2 flowPatchDto = new FlowPatchV2( new FlowPatchEndpoint(SRC_SWITCH_ID, SRC_PORT, SRC_VLAN, SRC_INNER_VLAN, SRC_DETECT_CONNECTED_DEVICES), new FlowPatchEndpoint(DST_SWITCH_ID, DST_PORT, DST_VLAN, DST_INNER_VLAN, DST_DETECT_CONNECTED_DEVICES), LATENCY, PRIORITY, PERIODIC_PINGS, TARGET_PATH_COMPUTATION_STRATEGY, DIVERSE_FLOW_ID, (long) BANDWIDTH, ALLOCATE_PROTECTED_PATH, PINNED, IGNORE_BANDWIDTH, DESCRIPTION, ENCAPSULATION_TYPE, PATH_COMPUTATION_STRATEGY); FlowPatch flowPatch = flowMapper.toFlowPatch(flowPatchDto); assertEquals(flowPatchDto.getSource().getSwitchId(), flowPatch.getSource().getSwitchId()); assertEquals(flowPatchDto.getSource().getPortNumber(), flowPatch.getSource().getPortNumber()); assertEquals(flowPatchDto.getSource().getVlanId(), flowPatch.getSource().getVlanId()); assertEquals(flowPatchDto.getSource().getInnerVlanId(), flowPatch.getSource().getInnerVlanId()); assertEquals(flowPatchDto.getSource().getDetectConnectedDevices().isLldp(), flowPatch.getSource().getTrackLldpConnectedDevices()); assertEquals(flowPatchDto.getSource().getDetectConnectedDevices().isArp(), flowPatch.getSource().getTrackArpConnectedDevices()); assertEquals(flowPatchDto.getDestination().getSwitchId(), flowPatch.getDestination().getSwitchId()); assertEquals(flowPatchDto.getDestination().getPortNumber(), flowPatch.getDestination().getPortNumber()); assertEquals(flowPatchDto.getDestination().getVlanId(), flowPatch.getDestination().getVlanId()); assertEquals(flowPatchDto.getDestination().getInnerVlanId(), flowPatch.getDestination().getInnerVlanId()); assertEquals(flowPatchDto.getDestination().getDetectConnectedDevices().isLldp(), flowPatch.getDestination().getTrackLldpConnectedDevices()); assertEquals(flowPatchDto.getDestination().getDetectConnectedDevices().isArp(), flowPatch.getDestination().getTrackArpConnectedDevices()); assertEquals(flowPatchDto.getMaxLatency() * 1000000L, (long) flowPatch.getMaxLatency()); assertEquals(flowPatchDto.getPriority(), flowPatch.getPriority()); assertEquals(flowPatchDto.getPeriodicPings(), flowPatch.getPeriodicPings()); assertEquals(flowPatchDto.getTargetPathComputationStrategy(), flowPatch.getTargetPathComputationStrategy().name().toLowerCase()); assertEquals(flowPatchDto.getDiverseFlowId(), flowPatch.getDiverseFlowId()); assertEquals(flowPatchDto.getMaximumBandwidth(), flowPatch.getBandwidth()); assertEquals(flowPatchDto.getAllocateProtectedPath(), flowPatch.getAllocateProtectedPath()); assertEquals(flowPatchDto.getPinned(), flowPatch.getPinned()); assertEquals(flowPatchDto.getIgnoreBandwidth(), flowPatch.getIgnoreBandwidth()); assertEquals(flowPatchDto.getDescription(), flowPatch.getDescription()); assertEquals(flowPatchDto.getEncapsulationType(), flowPatch.getEncapsulationType().name().toLowerCase()); assertEquals(flowPatchDto.getPathComputationStrategy(), flowPatch.getPathComputationStrategy().name().toLowerCase()); }
|
@Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto);
|
FlowMapper { @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); }
|
FlowMapper { @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); }
|
FlowMapper { @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
FlowMapper { @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) public abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); FlowPayload toFlowOutput(FlowDto f); FlowResponsePayload toFlowResponseOutput(FlowDto f); FlowResponseV2 toFlowResponseV2(FlowDto flowDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "targetPathComputationStrategy", source = "targetPathComputationStrategy") @Mapping(target = "source", ignore = true) @Mapping(target = "destination", ignore = true) @Mapping(target = "bandwidth", ignore = true) @Mapping(target = "allocateProtectedPath", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "pathComputationStrategy", ignore = true) @Mapping(target = "pinned", ignore = true) @Mapping(target = "ignoreBandwidth", ignore = true) @Mapping(target = "description", ignore = true) @Mapping(target = "encapsulationType", ignore = true) abstract FlowPatch toFlowPatch(FlowPatchDto flowPatchDto); @Mapping(target = "flowId", ignore = true) @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "allocateProtectedPath", source = "allocateProtectedPath") @Mapping(target = "maxLatency", expression = "java(flowPatchDto.getMaxLatency() != null ? flowPatchDto.getMaxLatency() * 1000000L : null)") @Mapping(target = "priority", source = "priority") @Mapping(target = "periodicPings", source = "periodicPings") @Mapping(target = "diverseFlowId", source = "diverseFlowId") abstract FlowPatch toFlowPatch(FlowPatchV2 flowPatchDto); @Mapping(target = "trackLldpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isLldp() : null)") @Mapping(target = "trackArpConnectedDevices", expression = "java(flowPatchEndpoint.getDetectConnectedDevices() != null ? " + "flowPatchEndpoint.getDetectConnectedDevices().isArp() : null)") abstract PatchEndpoint toPatchEndpoint(FlowPatchEndpoint flowPatchEndpoint); @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", expression = "java(new DetectConnectedDevicesDto(" + "request.getSource().getDetectConnectedDevices().isLldp(), " + "request.getSource().getDetectConnectedDevices().isArp(), " + "request.getDestination().getDetectConnectedDevices().isLldp(), " + "request.getDestination().getDetectConnectedDevices().isArp()))") @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "maxLatency", expression = "java(request.getMaxLatency() != null ? request.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowRequestV2 request); @Mapping(target = "flowId", source = "id") @Mapping(target = "bandwidth", source = "maximumBandwidth") @Mapping(target = "detectConnectedDevices", ignore = true) @Mapping(target = "transitEncapsulationId", ignore = true) @Mapping(target = "type", ignore = true) @Mapping(target = "bulkUpdateFlowIds", ignore = true) @Mapping(target = "doNotRevert", ignore = true) @Mapping(target = "diverseFlowId", ignore = true) @Mapping(target = "maxLatency", expression = "java(payload.getMaxLatency() != null ? payload.getMaxLatency() * 1000000L : null)") abstract FlowRequest toFlowRequest(FlowPayload payload); @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointV2 input); @Mapping(target = "switchId", source = "datapath") @Mapping(target = "outerVlanId", source = "vlanId") @Mapping(target = "trackLldpConnectedDevices", source = "detectConnectedDevices.lldp") @Mapping(target = "trackArpConnectedDevices", source = "detectConnectedDevices.arp") abstract FlowEndpoint mapFlowEndpoint(FlowEndpointPayload input); FlowRequest toFlowCreateRequest(FlowRequestV2 source); FlowRequest toFlowCreateRequest(FlowCreatePayload source); FlowRequest toFlowUpdateRequest(FlowUpdatePayload source); abstract PingOutput toPingOutput(FlowPingResponse response); @Mapping(source = "flowId", target = "id") @Mapping(source = "path", target = "path") @Mapping(source = "rerouted", target = "rerouted") abstract FlowReroutePayload toReroutePayload(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "path") abstract FlowRerouteResponseV2 toRerouteResponseV2(String flowId, PathInfoData path, boolean rerouted); @Mapping(source = "path", target = "nodes") abstract FlowPathV2 toFlowPathV2(PathInfoData path); @Mapping(target = "segmentLatency", ignore = true) abstract FlowPathV2.PathNodeV2 toPathNodeV2(PathNode pathNode); @Mapping(source = "flowId", target = "id") @Mapping(source = "state", target = "status") abstract FlowIdStatusPayload toFlowIdStatusPayload(FlowDto flow); @Mapping(target = "latency", source = "meters.networkLatency") abstract UniFlowPingOutput toUniFlowPing(UniFlowPingResponse response); SwapFlowPayload toSwapOutput(FlowDto flowDto); @Mapping(target = "sourceSwitch", expression = "java(request.getSource().getSwitchId())") @Mapping(target = "destinationSwitch", expression = "java(request.getDestination().getSwitchId())") @Mapping(target = "sourcePort", expression = "java(request.getSource().getPortNumber())") @Mapping(target = "destinationPort", expression = "java(request.getDestination().getPortNumber())") @Mapping(target = "sourceVlan", expression = "java(request.getSource().getVlanId())") @Mapping(target = "destinationVlan", expression = "java(request.getDestination().getVlanId())") abstract SwapFlowDto toSwapFlowDto(SwapFlowPayload request); abstract FlowValidationDto toFlowValidationDto(FlowValidationResponse response); String encodeFlowState(FlowState state); @Mapping(target = "mainPath", source = "mainFlowPathStatus") @Mapping(target = "protectedPath", source = "protectedFlowPathStatus") abstract PathStatus map(FlowStatusDetails flowStatusDetails); String map(FlowPathStatus flowPathStatus); String map(FlowEncapsulationType encapsulationType); FlowEncapsulationType map(String encapsulationType); String map(PathComputationStrategy pathComputationStrategy); PathComputationStrategy mapPathComputationStrategy(String pathComputationStrategy); org.openkilda.model.FlowEncapsulationType mapEncapsulationType(String encapsulationType); String getPingError(Ping.Errors error); }
|
@Test public void shouldPassValidationForValidConfig() { Properties source = new Properties(); source.setProperty(TEST_KEY, String.valueOf(VALID_TEST_VALUE)); ValidatingConfigurationProvider provider = new ValidatingConfigurationProvider( new PropertiesConfigurationSource(source), new JdkProxyStaticConfigurationFactory()); TestConfig config = provider.getConfiguration(TestConfig.class); assertEquals(VALID_TEST_VALUE, config.getTestProperty()); }
|
@Override public <T> T getConfiguration(Class<T> configurationType) { requireNonNull(configurationType, "configurationType cannot be null"); T instance = factory.createConfiguration(configurationType, source); Set<ConstraintViolation<T>> errors = validator.validate(instance); if (!errors.isEmpty()) { Set<String> errorDetails = errors.stream() .map(v -> v.getPropertyPath() + " " + v.getMessage()) .collect(toSet()); throw new ConfigurationException( format("The configuration value(s) for %s violate constraint(s): %s", configurationType.getSimpleName(), String.join(";", errorDetails)), errorDetails); } return instance; }
|
ValidatingConfigurationProvider implements ConfigurationProvider { @Override public <T> T getConfiguration(Class<T> configurationType) { requireNonNull(configurationType, "configurationType cannot be null"); T instance = factory.createConfiguration(configurationType, source); Set<ConstraintViolation<T>> errors = validator.validate(instance); if (!errors.isEmpty()) { Set<String> errorDetails = errors.stream() .map(v -> v.getPropertyPath() + " " + v.getMessage()) .collect(toSet()); throw new ConfigurationException( format("The configuration value(s) for %s violate constraint(s): %s", configurationType.getSimpleName(), String.join(";", errorDetails)), errorDetails); } return instance; } }
|
ValidatingConfigurationProvider implements ConfigurationProvider { @Override public <T> T getConfiguration(Class<T> configurationType) { requireNonNull(configurationType, "configurationType cannot be null"); T instance = factory.createConfiguration(configurationType, source); Set<ConstraintViolation<T>> errors = validator.validate(instance); if (!errors.isEmpty()) { Set<String> errorDetails = errors.stream() .map(v -> v.getPropertyPath() + " " + v.getMessage()) .collect(toSet()); throw new ConfigurationException( format("The configuration value(s) for %s violate constraint(s): %s", configurationType.getSimpleName(), String.join(";", errorDetails)), errorDetails); } return instance; } ValidatingConfigurationProvider(ConfigurationSource source, ConfigurationFactory factory); }
|
ValidatingConfigurationProvider implements ConfigurationProvider { @Override public <T> T getConfiguration(Class<T> configurationType) { requireNonNull(configurationType, "configurationType cannot be null"); T instance = factory.createConfiguration(configurationType, source); Set<ConstraintViolation<T>> errors = validator.validate(instance); if (!errors.isEmpty()) { Set<String> errorDetails = errors.stream() .map(v -> v.getPropertyPath() + " " + v.getMessage()) .collect(toSet()); throw new ConfigurationException( format("The configuration value(s) for %s violate constraint(s): %s", configurationType.getSimpleName(), String.join(";", errorDetails)), errorDetails); } return instance; } ValidatingConfigurationProvider(ConfigurationSource source, ConfigurationFactory factory); @Override T getConfiguration(Class<T> configurationType); }
|
ValidatingConfigurationProvider implements ConfigurationProvider { @Override public <T> T getConfiguration(Class<T> configurationType) { requireNonNull(configurationType, "configurationType cannot be null"); T instance = factory.createConfiguration(configurationType, source); Set<ConstraintViolation<T>> errors = validator.validate(instance); if (!errors.isEmpty()) { Set<String> errorDetails = errors.stream() .map(v -> v.getPropertyPath() + " " + v.getMessage()) .collect(toSet()); throw new ConfigurationException( format("The configuration value(s) for %s violate constraint(s): %s", configurationType.getSimpleName(), String.join(";", errorDetails)), errorDetails); } return instance; } ValidatingConfigurationProvider(ConfigurationSource source, ConfigurationFactory factory); @Override T getConfiguration(Class<T> configurationType); }
|
@Test public void shouldFailValidationForInvalidConfig() { Properties source = new Properties(); source.setProperty(TEST_KEY, String.valueOf(INVALID_TEST_VALUE)); ValidatingConfigurationProvider provider = new ValidatingConfigurationProvider( new PropertiesConfigurationSource(source), new JdkProxyStaticConfigurationFactory()); expectedException.expect(ConfigurationException.class); provider.getConfiguration(TestConfig.class); }
|
@Override public <T> T getConfiguration(Class<T> configurationType) { requireNonNull(configurationType, "configurationType cannot be null"); T instance = factory.createConfiguration(configurationType, source); Set<ConstraintViolation<T>> errors = validator.validate(instance); if (!errors.isEmpty()) { Set<String> errorDetails = errors.stream() .map(v -> v.getPropertyPath() + " " + v.getMessage()) .collect(toSet()); throw new ConfigurationException( format("The configuration value(s) for %s violate constraint(s): %s", configurationType.getSimpleName(), String.join(";", errorDetails)), errorDetails); } return instance; }
|
ValidatingConfigurationProvider implements ConfigurationProvider { @Override public <T> T getConfiguration(Class<T> configurationType) { requireNonNull(configurationType, "configurationType cannot be null"); T instance = factory.createConfiguration(configurationType, source); Set<ConstraintViolation<T>> errors = validator.validate(instance); if (!errors.isEmpty()) { Set<String> errorDetails = errors.stream() .map(v -> v.getPropertyPath() + " " + v.getMessage()) .collect(toSet()); throw new ConfigurationException( format("The configuration value(s) for %s violate constraint(s): %s", configurationType.getSimpleName(), String.join(";", errorDetails)), errorDetails); } return instance; } }
|
ValidatingConfigurationProvider implements ConfigurationProvider { @Override public <T> T getConfiguration(Class<T> configurationType) { requireNonNull(configurationType, "configurationType cannot be null"); T instance = factory.createConfiguration(configurationType, source); Set<ConstraintViolation<T>> errors = validator.validate(instance); if (!errors.isEmpty()) { Set<String> errorDetails = errors.stream() .map(v -> v.getPropertyPath() + " " + v.getMessage()) .collect(toSet()); throw new ConfigurationException( format("The configuration value(s) for %s violate constraint(s): %s", configurationType.getSimpleName(), String.join(";", errorDetails)), errorDetails); } return instance; } ValidatingConfigurationProvider(ConfigurationSource source, ConfigurationFactory factory); }
|
ValidatingConfigurationProvider implements ConfigurationProvider { @Override public <T> T getConfiguration(Class<T> configurationType) { requireNonNull(configurationType, "configurationType cannot be null"); T instance = factory.createConfiguration(configurationType, source); Set<ConstraintViolation<T>> errors = validator.validate(instance); if (!errors.isEmpty()) { Set<String> errorDetails = errors.stream() .map(v -> v.getPropertyPath() + " " + v.getMessage()) .collect(toSet()); throw new ConfigurationException( format("The configuration value(s) for %s violate constraint(s): %s", configurationType.getSimpleName(), String.join(";", errorDetails)), errorDetails); } return instance; } ValidatingConfigurationProvider(ConfigurationSource source, ConfigurationFactory factory); @Override T getConfiguration(Class<T> configurationType); }
|
ValidatingConfigurationProvider implements ConfigurationProvider { @Override public <T> T getConfiguration(Class<T> configurationType) { requireNonNull(configurationType, "configurationType cannot be null"); T instance = factory.createConfiguration(configurationType, source); Set<ConstraintViolation<T>> errors = validator.validate(instance); if (!errors.isEmpty()) { Set<String> errorDetails = errors.stream() .map(v -> v.getPropertyPath() + " " + v.getMessage()) .collect(toSet()); throw new ConfigurationException( format("The configuration value(s) for %s violate constraint(s): %s", configurationType.getSimpleName(), String.join(";", errorDetails)), errorDetails); } return instance; } ValidatingConfigurationProvider(ConfigurationSource source, ConfigurationFactory factory); @Override T getConfiguration(Class<T> configurationType); }
|
@Test public void buildTsdbTupleFromIslOneWayLatency() throws JsonEncodeException, IOException { List<Object> tsdbTuple = statsBolt.buildTsdbTuple( SWITCH1_ID, NODE1.getPortNo(), SWITCH2_ID, NODE2.getPortNo(), LATENCY, TIMESTAMP); assertTsdbTuple(tsdbTuple); }
|
@VisibleForTesting List<Object> buildTsdbTuple(SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency, long timestamp) throws JsonProcessingException { Map<String, String> tags = new HashMap<>(); tags.put("src_switch", srcSwitchId.toOtsdFormat()); tags.put("src_port", String.valueOf(srcPort)); tags.put("dst_switch", dstSwitchId.toOtsdFormat()); tags.put("dst_port", String.valueOf(dstPort)); return tsdbTuple(metricFormatter.format(LATENCY_METRIC_NAME), timestamp, latency, tags); }
|
IslStatsBolt extends AbstractBolt implements IslStatsCarrier { @VisibleForTesting List<Object> buildTsdbTuple(SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency, long timestamp) throws JsonProcessingException { Map<String, String> tags = new HashMap<>(); tags.put("src_switch", srcSwitchId.toOtsdFormat()); tags.put("src_port", String.valueOf(srcPort)); tags.put("dst_switch", dstSwitchId.toOtsdFormat()); tags.put("dst_port", String.valueOf(dstPort)); return tsdbTuple(metricFormatter.format(LATENCY_METRIC_NAME), timestamp, latency, tags); } }
|
IslStatsBolt extends AbstractBolt implements IslStatsCarrier { @VisibleForTesting List<Object> buildTsdbTuple(SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency, long timestamp) throws JsonProcessingException { Map<String, String> tags = new HashMap<>(); tags.put("src_switch", srcSwitchId.toOtsdFormat()); tags.put("src_port", String.valueOf(srcPort)); tags.put("dst_switch", dstSwitchId.toOtsdFormat()); tags.put("dst_port", String.valueOf(dstPort)); return tsdbTuple(metricFormatter.format(LATENCY_METRIC_NAME), timestamp, latency, tags); } IslStatsBolt(String metricPrefix, long latencyTimeout); }
|
IslStatsBolt extends AbstractBolt implements IslStatsCarrier { @VisibleForTesting List<Object> buildTsdbTuple(SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency, long timestamp) throws JsonProcessingException { Map<String, String> tags = new HashMap<>(); tags.put("src_switch", srcSwitchId.toOtsdFormat()); tags.put("src_port", String.valueOf(srcPort)); tags.put("dst_switch", dstSwitchId.toOtsdFormat()); tags.put("dst_port", String.valueOf(dstPort)); return tsdbTuple(metricFormatter.format(LATENCY_METRIC_NAME), timestamp, latency, tags); } IslStatsBolt(String metricPrefix, long latencyTimeout); @Override void emitLatency(SwitchId srcSwitch, int srcPort, SwitchId dstSwitch, int dstPort,
long latency, long timestamp); @Override void declareOutputFields(OutputFieldsDeclarer declarer); }
|
IslStatsBolt extends AbstractBolt implements IslStatsCarrier { @VisibleForTesting List<Object> buildTsdbTuple(SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency, long timestamp) throws JsonProcessingException { Map<String, String> tags = new HashMap<>(); tags.put("src_switch", srcSwitchId.toOtsdFormat()); tags.put("src_port", String.valueOf(srcPort)); tags.put("dst_switch", dstSwitchId.toOtsdFormat()); tags.put("dst_port", String.valueOf(dstPort)); return tsdbTuple(metricFormatter.format(LATENCY_METRIC_NAME), timestamp, latency, tags); } IslStatsBolt(String metricPrefix, long latencyTimeout); @Override void emitLatency(SwitchId srcSwitch, int srcPort, SwitchId dstSwitch, int dstPort,
long latency, long timestamp); @Override void declareOutputFields(OutputFieldsDeclarer declarer); static final String LATENCY_METRIC_NAME; }
|
@Test public void isRecordStillValidTest() { assertFalse(islStatsService.isRecordStillValid(new LatencyRecord(1, 0))); long expiredTimestamp = Instant.now().minusSeconds(LATENCY_TIMEOUT * 2).toEpochMilli(); assertFalse(islStatsService.isRecordStillValid(new LatencyRecord(1, expiredTimestamp))); assertTrue(islStatsService.isRecordStillValid(new LatencyRecord(1, System.currentTimeMillis()))); long freshTimestamp = Instant.now().plusSeconds(LATENCY_TIMEOUT * 2).toEpochMilli(); assertTrue(islStatsService.isRecordStillValid(new LatencyRecord(1, freshTimestamp))); }
|
@VisibleForTesting boolean isRecordStillValid(LatencyRecord record) { Instant expirationTime = Instant.ofEpochMilli(record.getTimestamp()) .plusSeconds(latencyTimeout); return Instant.now().isBefore(expirationTime); }
|
IslStatsService { @VisibleForTesting boolean isRecordStillValid(LatencyRecord record) { Instant expirationTime = Instant.ofEpochMilli(record.getTimestamp()) .plusSeconds(latencyTimeout); return Instant.now().isBefore(expirationTime); } }
|
IslStatsService { @VisibleForTesting boolean isRecordStillValid(LatencyRecord record) { Instant expirationTime = Instant.ofEpochMilli(record.getTimestamp()) .plusSeconds(latencyTimeout); return Instant.now().isBefore(expirationTime); } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); }
|
IslStatsService { @VisibleForTesting boolean isRecordStillValid(LatencyRecord record) { Instant expirationTime = Instant.ofEpochMilli(record.getTimestamp()) .plusSeconds(latencyTimeout); return Instant.now().isBefore(expirationTime); } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
IslStatsService { @VisibleForTesting boolean isRecordStillValid(LatencyRecord record) { Instant expirationTime = Instant.ofEpochMilli(record.getTimestamp()) .plusSeconds(latencyTimeout); return Instant.now().isBefore(expirationTime); } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
@Test public void handleOneWayLatencyEmitOnIslDownTest() { List<LatencyRecord> buffer = new ArrayList<>(); Instant time = Instant.now().minusSeconds(LATENCY_TIMEOUT).minusMillis(500); for (int i = 0; i < 4; i++) { sendForwardOneWayLatency(i, time); verifyNoMoreInteractions(carrier); buffer.add(new LatencyRecord(i, time.toEpochMilli())); time = time.plusSeconds(1); } buffer.remove(0); islStatsService.handleIstStatusUpdateNotification( new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE)); assertEmitLatency(buffer); }
|
public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
@Test public void isCookieMismatch1() { OfInput input = makeInput(U64.of(-1)); Assert.assertFalse(input.packetInCookieMismatchAll(callerLogger, cookieAlpha)); input = makeInput(U64.ZERO); Assert.assertFalse(input.packetInCookieMismatchAll(callerLogger, cookieAlpha)); }
|
public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } OfInput(IOFSwitch sw, OFMessage message, FloodlightContext context); }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } OfInput(IOFSwitch sw, OFMessage message, FloodlightContext context); U64 packetInCookie(); boolean packetInCookieMismatchAll(Logger log, U64... expected); OFType getType(); long getReceiveTime(); DatapathId getDpId(); OFMessage getMessage(); Long getLatency(); Ethernet getPacketInPayload(); OFPort getPort(); @Override String toString(); }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } OfInput(IOFSwitch sw, OFMessage message, FloodlightContext context); U64 packetInCookie(); boolean packetInCookieMismatchAll(Logger log, U64... expected); OFType getType(); long getReceiveTime(); DatapathId getDpId(); OFMessage getMessage(); Long getLatency(); Ethernet getPacketInPayload(); OFPort getPort(); @Override String toString(); }
|
@Test public void handleOneWayLatencyIslMovedTest() { Instant time = Instant.now().minusSeconds(LATENCY_TIMEOUT).minusMillis(500); for (int i = 0; i < 4; i++) { sendForwardOneWayLatency(i, time); verifyNoMoreInteractions(carrier); time = time.plusSeconds(1); } islStatsService.handleIstStatusUpdateNotification( new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, MOVED)); verifyNoMoreInteractions(carrier); }
|
public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
@Test public void handleOneWayLatencyEmitOnEachIslDownTest() throws InterruptedException { List<LatencyRecord> buffer = new ArrayList<>(); Instant time = Instant.now().minusSeconds(LATENCY_TIMEOUT).minusMillis(500); for (int i = 0; i < 4; i++) { sendForwardOneWayLatency(i, time); verifyNoMoreInteractions(carrier); buffer.add(new LatencyRecord(i, time.toEpochMilli())); time = time.plusSeconds(1); } buffer.remove(0); islStatsService.handleIstStatusUpdateNotification( new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE)); time = Instant.now(); int secondPartOfPacketsSize = 4; for (int i = 0; i < secondPartOfPacketsSize; i++) { sendForwardOneWayLatency(i + secondPartOfPacketsSize, time); buffer.add(new LatencyRecord(i + secondPartOfPacketsSize, time.toEpochMilli())); time = time.plusMillis(500); sleep(50); } islStatsService.handleIstStatusUpdateNotification( new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE)); assertEmitLatency(buffer); }
|
public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
@Test public void handleOneWayLatencyEmitOnFirstIslDownTest() throws InterruptedException { List<LatencyRecord> buffer = new ArrayList<>(); Instant time = Instant.now().minusSeconds(LATENCY_TIMEOUT).minusMillis(500); for (int i = 0; i < 4; i++) { sendForwardOneWayLatency(i, time); verifyNoMoreInteractions(carrier); buffer.add(new LatencyRecord(i, time.toEpochMilli())); time = time.plusSeconds(1); } buffer.remove(0); islStatsService.handleIstStatusUpdateNotification( new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE)); time = Instant.now(); int secondPartOfPacketsSize = 4; for (int i = 0; i < secondPartOfPacketsSize; i++) { sendForwardOneWayLatency(i + secondPartOfPacketsSize, time); time = time.plusMillis(500); sleep(50); } assertEmitLatency(buffer); }
|
public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
@Test public void handleOneWayLatencyNoEmitOnEachIslMoveTest() throws InterruptedException { Instant time = Instant.now().minusSeconds(LATENCY_TIMEOUT - 1); for (int i = 0; i < 4; i++) { sendForwardOneWayLatency(i, time); time = time.plusSeconds(1); } islStatsService.handleIstStatusUpdateNotification( new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, MOVED)); time = time.plusSeconds(LATENCY_TIMEOUT + 1); int secondPartOfPacketsSize = 4; for (int i = 0; i < secondPartOfPacketsSize; i++) { sendForwardOneWayLatency(i + secondPartOfPacketsSize, time); time = time.plusMillis(50); sleep(50); } islStatsService.handleIstStatusUpdateNotification( new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, MOVED)); verifyNoMoreInteractions(carrier); }
|
public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
IslStatsService { public void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification) { IslKey key = new IslKey(notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); if (notification.getStatus() == IslStatus.MOVED) { handleIslMoved(key); handleIslMoved(key.getReverse()); } else if (notification.getStatus() == IslStatus.INACTIVE) { handleIslDown(key); handleIslDown(key.getReverse()); } } IslStatsService(IslStatsCarrier carrier, long latencyTimeout); void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination); void handleOneWayLatencyMetric(long timestamp, IslOneWayLatency data); void handleIstStatusUpdateNotification(IslStatusUpdateNotification notification); }
|
@Test() public void handleGetDataFromCacheTest() { IslRoundTripLatency forward = new IslRoundTripLatency(SWITCH_ID_1, PORT_1, 1, 0L); IslRoundTripLatency reverse = new IslRoundTripLatency(SWITCH_ID_2, PORT_2, 1, 0L); checkHandleGetDataFromCache(forward, SWITCH_ID_2, PORT_2); checkHandleGetDataFromCache(reverse, SWITCH_ID_1, PORT_1); }
|
public void handleGetDataFromCache(IslRoundTripLatency roundTripLatency) { Endpoint source = Endpoint.of(roundTripLatency.getSrcSwitchId(), roundTripLatency.getSrcPortNo()); Endpoint destination = cache.get(source); try { if (destination == null) { destination = updateCache(source); } carrier.emitCachedData(roundTripLatency, destination); } catch (IslNotFoundException e) { log.debug(String.format("Could not update ISL cache: %s", e.getMessage()), e); } catch (IllegalIslStateException e) { log.error(String.format("Could not update ISL cache: %s", e.getMessage()), e); } }
|
CacheService { public void handleGetDataFromCache(IslRoundTripLatency roundTripLatency) { Endpoint source = Endpoint.of(roundTripLatency.getSrcSwitchId(), roundTripLatency.getSrcPortNo()); Endpoint destination = cache.get(source); try { if (destination == null) { destination = updateCache(source); } carrier.emitCachedData(roundTripLatency, destination); } catch (IslNotFoundException e) { log.debug(String.format("Could not update ISL cache: %s", e.getMessage()), e); } catch (IllegalIslStateException e) { log.error(String.format("Could not update ISL cache: %s", e.getMessage()), e); } } }
|
CacheService { public void handleGetDataFromCache(IslRoundTripLatency roundTripLatency) { Endpoint source = Endpoint.of(roundTripLatency.getSrcSwitchId(), roundTripLatency.getSrcPortNo()); Endpoint destination = cache.get(source); try { if (destination == null) { destination = updateCache(source); } carrier.emitCachedData(roundTripLatency, destination); } catch (IslNotFoundException e) { log.debug(String.format("Could not update ISL cache: %s", e.getMessage()), e); } catch (IllegalIslStateException e) { log.error(String.format("Could not update ISL cache: %s", e.getMessage()), e); } } CacheService(CacheCarrier carrier, RepositoryFactory repositoryFactory); }
|
CacheService { public void handleGetDataFromCache(IslRoundTripLatency roundTripLatency) { Endpoint source = Endpoint.of(roundTripLatency.getSrcSwitchId(), roundTripLatency.getSrcPortNo()); Endpoint destination = cache.get(source); try { if (destination == null) { destination = updateCache(source); } carrier.emitCachedData(roundTripLatency, destination); } catch (IslNotFoundException e) { log.debug(String.format("Could not update ISL cache: %s", e.getMessage()), e); } catch (IllegalIslStateException e) { log.error(String.format("Could not update ISL cache: %s", e.getMessage()), e); } } CacheService(CacheCarrier carrier, RepositoryFactory repositoryFactory); void handleUpdateCache(IslStatusUpdateNotification notification); void handleGetDataFromCache(IslRoundTripLatency roundTripLatency); }
|
CacheService { public void handleGetDataFromCache(IslRoundTripLatency roundTripLatency) { Endpoint source = Endpoint.of(roundTripLatency.getSrcSwitchId(), roundTripLatency.getSrcPortNo()); Endpoint destination = cache.get(source); try { if (destination == null) { destination = updateCache(source); } carrier.emitCachedData(roundTripLatency, destination); } catch (IslNotFoundException e) { log.debug(String.format("Could not update ISL cache: %s", e.getMessage()), e); } catch (IllegalIslStateException e) { log.error(String.format("Could not update ISL cache: %s", e.getMessage()), e); } } CacheService(CacheCarrier carrier, RepositoryFactory repositoryFactory); void handleUpdateCache(IslStatusUpdateNotification notification); void handleGetDataFromCache(IslRoundTripLatency roundTripLatency); }
|
@Test() public void handleUpdateCacheInactiveTest() { IslStatusUpdateNotification notification = new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE); updateIslStatus(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE); updateIslStatus(SWITCH_ID_2, PORT_2, SWITCH_ID_1, PORT_1, INACTIVE); cacheService.handleUpdateCache(notification); IslRoundTripLatency forward = new IslRoundTripLatency(SWITCH_ID_1, PORT_1, 1, 0L); checkHandleGetDataFromCache(forward, SWITCH_ID_2, PORT_2); IslRoundTripLatency reverse = new IslRoundTripLatency(SWITCH_ID_2, PORT_2, 1, 0L); checkHandleGetDataFromCache(reverse, SWITCH_ID_1, PORT_1); }
|
public void handleUpdateCache(IslStatusUpdateNotification notification) { if (notification.getStatus() == IslStatus.MOVED || notification.getStatus() == IslStatus.INACTIVE) { Endpoint source = Endpoint.of(notification.getSrcSwitchId(), notification.getSrcPortNo()); Endpoint destination = Endpoint.of(notification.getDstSwitchId(), notification.getDstPortNo()); cache.remove(source); cache.remove(destination); log.info("Remove ISL {}_{} ===> {}_{} from isl latency cache", notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); } }
|
CacheService { public void handleUpdateCache(IslStatusUpdateNotification notification) { if (notification.getStatus() == IslStatus.MOVED || notification.getStatus() == IslStatus.INACTIVE) { Endpoint source = Endpoint.of(notification.getSrcSwitchId(), notification.getSrcPortNo()); Endpoint destination = Endpoint.of(notification.getDstSwitchId(), notification.getDstPortNo()); cache.remove(source); cache.remove(destination); log.info("Remove ISL {}_{} ===> {}_{} from isl latency cache", notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); } } }
|
CacheService { public void handleUpdateCache(IslStatusUpdateNotification notification) { if (notification.getStatus() == IslStatus.MOVED || notification.getStatus() == IslStatus.INACTIVE) { Endpoint source = Endpoint.of(notification.getSrcSwitchId(), notification.getSrcPortNo()); Endpoint destination = Endpoint.of(notification.getDstSwitchId(), notification.getDstPortNo()); cache.remove(source); cache.remove(destination); log.info("Remove ISL {}_{} ===> {}_{} from isl latency cache", notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); } } CacheService(CacheCarrier carrier, RepositoryFactory repositoryFactory); }
|
CacheService { public void handleUpdateCache(IslStatusUpdateNotification notification) { if (notification.getStatus() == IslStatus.MOVED || notification.getStatus() == IslStatus.INACTIVE) { Endpoint source = Endpoint.of(notification.getSrcSwitchId(), notification.getSrcPortNo()); Endpoint destination = Endpoint.of(notification.getDstSwitchId(), notification.getDstPortNo()); cache.remove(source); cache.remove(destination); log.info("Remove ISL {}_{} ===> {}_{} from isl latency cache", notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); } } CacheService(CacheCarrier carrier, RepositoryFactory repositoryFactory); void handleUpdateCache(IslStatusUpdateNotification notification); void handleGetDataFromCache(IslRoundTripLatency roundTripLatency); }
|
CacheService { public void handleUpdateCache(IslStatusUpdateNotification notification) { if (notification.getStatus() == IslStatus.MOVED || notification.getStatus() == IslStatus.INACTIVE) { Endpoint source = Endpoint.of(notification.getSrcSwitchId(), notification.getSrcPortNo()); Endpoint destination = Endpoint.of(notification.getDstSwitchId(), notification.getDstPortNo()); cache.remove(source); cache.remove(destination); log.info("Remove ISL {}_{} ===> {}_{} from isl latency cache", notification.getSrcSwitchId(), notification.getSrcPortNo(), notification.getDstSwitchId(), notification.getDstPortNo()); } } CacheService(CacheCarrier carrier, RepositoryFactory repositoryFactory); void handleUpdateCache(IslStatusUpdateNotification notification); void handleGetDataFromCache(IslRoundTripLatency roundTripLatency); }
|
@Test(expected = IslNotFoundException.class) public void updateIslLatencyNonExistentSrcEndpointTest() throws IslNotFoundException, SwitchNotFoundException { islLatencyService.updateIslLatency(NON_EXISTENT_SWITCH_ID, PORT_1, SWITCH_ID_2, PORT_2, 0); }
|
@VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); static final String ONE_WAY_LATENCY; static final String ROUND_TRIP_LATENCY; }
|
@Test(expected = IslNotFoundException.class) public void updateIslLatencyNonExistentDstEndpointTest() throws IslNotFoundException, SwitchNotFoundException { islLatencyService.updateIslLatency(SWITCH_ID_1, PORT_1, NON_EXISTENT_SWITCH_ID, PORT_2, 0); }
|
@VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); static final String ONE_WAY_LATENCY; static final String ROUND_TRIP_LATENCY; }
|
@Test(expected = IslNotFoundException.class) public void updateIslLatencyNonExistentIslTest() throws IslNotFoundException, SwitchNotFoundException { islLatencyService.updateIslLatency(SWITCH_ID_1, NON_EXISTENT_PORT, SWITCH_ID_2, NON_EXISTENT_PORT, 0); }
|
@VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); static final String ONE_WAY_LATENCY; static final String ROUND_TRIP_LATENCY; }
|
@Test public void updateIslLatencyTest() throws IslNotFoundException, SwitchNotFoundException { islLatencyService.updateIslLatency(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, 1000); assertForwardLatency(1000); }
|
@VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); }
|
IslLatencyService { @VisibleForTesting void updateIslLatency( SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException { transactionManager.doInTransaction(() -> { Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort) .orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort)); isl.setLatency(latency); }); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); static final String ONE_WAY_LATENCY; static final String ROUND_TRIP_LATENCY; }
|
@Test public void isCookieMismatch3() { OfInput input = makeInput(cookieAlpha); Assert.assertTrue(input.packetInCookieMismatchAll(callerLogger, cookieBeta)); }
|
public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } OfInput(IOFSwitch sw, OFMessage message, FloodlightContext context); }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } OfInput(IOFSwitch sw, OFMessage message, FloodlightContext context); U64 packetInCookie(); boolean packetInCookieMismatchAll(Logger log, U64... expected); OFType getType(); long getReceiveTime(); DatapathId getDpId(); OFMessage getMessage(); Long getLatency(); Ethernet getPacketInPayload(); OFPort getPort(); @Override String toString(); }
|
OfInput { public boolean packetInCookieMismatchAll(Logger log, U64... expected) { boolean isMismatched = packetInCookieMismatchCheck(expected); if (isMismatched) { log.debug("{} - cookie mismatch (expected one of:{}, actual:{})", this, expected, packetInCookie()); } return isMismatched; } OfInput(IOFSwitch sw, OFMessage message, FloodlightContext context); U64 packetInCookie(); boolean packetInCookieMismatchAll(Logger log, U64... expected); OFType getType(); long getReceiveTime(); DatapathId getDpId(); OFMessage getMessage(); Long getLatency(); Ethernet getPacketInPayload(); OFPort getPort(); @Override String toString(); }
|
@Test(expected = IllegalSwitchPropertiesException.class) public void shouldValidateFlowWithLldpFlagWhenUpdatingSwitchProperties() { Switch firstSwitch = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build(); Switch secondSwitch = Switch.builder().switchId(TEST_SWITCH_ID_2).status(SwitchStatus.ACTIVE).build(); switchRepository.add(firstSwitch); switchRepository.add(secondSwitch); Flow flow = Flow.builder() .flowId(TEST_FLOW_ID_1) .srcSwitch(firstSwitch) .destSwitch(secondSwitch) .detectConnectedDevices(new DetectConnectedDevices( true, false, true, false, false, false, false, false)) .build(); flowRepository.add(flow); createSwitchProperties( firstSwitch, Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN), true, false, false); SwitchPropertiesDto update = new SwitchPropertiesDto(); update.setSupportedTransitEncapsulation( Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN)); update.setMultiTable(false); update.setSwitchLldp(false); switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update); }
|
public SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto) { if (isEmpty(switchPropertiesDto.getSupportedTransitEncapsulation())) { throw new IllegalSwitchPropertiesException("Supported transit encapsulations should not be null or empty"); } SwitchProperties update = SwitchPropertiesMapper.INSTANCE.map(switchPropertiesDto); UpdateSwitchPropertiesResult result = transactionManager.doInTransaction(() -> { SwitchProperties switchProperties = switchPropertiesRepository.findBySwitchId(switchId) .orElseThrow(() -> new SwitchPropertiesNotFoundException(switchId)); validateSwitchProperties(switchId, update); final boolean isSwitchSyncNeeded = isSwitchSyncNeeded(switchProperties, update); switchProperties.setMultiTable(update.isMultiTable()); switchProperties.setSwitchLldp(update.isSwitchLldp()); switchProperties.setSwitchArp(update.isSwitchArp()); switchProperties.setSupportedTransitEncapsulation(update.getSupportedTransitEncapsulation()); switchProperties.setServer42FlowRtt(update.isServer42FlowRtt()); switchProperties.setServer42Port(update.getServer42Port()); switchProperties.setServer42Vlan(update.getServer42Vlan()); switchProperties.setServer42MacAddress(update.getServer42MacAddress()); return new UpdateSwitchPropertiesResult( SwitchPropertiesMapper.INSTANCE.map(switchProperties), isSwitchSyncNeeded); }); if (result.isSwitchSyncRequired()) { carrier.requestSwitchSync(switchId); } if (switchPropertiesDto.isServer42FlowRtt()) { carrier.enableServer42FlowRttOnSwitch(switchId); } else { carrier.disableServer42FlowRttOnSwitch(switchId); } return result.switchPropertiesDto; }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto) { if (isEmpty(switchPropertiesDto.getSupportedTransitEncapsulation())) { throw new IllegalSwitchPropertiesException("Supported transit encapsulations should not be null or empty"); } SwitchProperties update = SwitchPropertiesMapper.INSTANCE.map(switchPropertiesDto); UpdateSwitchPropertiesResult result = transactionManager.doInTransaction(() -> { SwitchProperties switchProperties = switchPropertiesRepository.findBySwitchId(switchId) .orElseThrow(() -> new SwitchPropertiesNotFoundException(switchId)); validateSwitchProperties(switchId, update); final boolean isSwitchSyncNeeded = isSwitchSyncNeeded(switchProperties, update); switchProperties.setMultiTable(update.isMultiTable()); switchProperties.setSwitchLldp(update.isSwitchLldp()); switchProperties.setSwitchArp(update.isSwitchArp()); switchProperties.setSupportedTransitEncapsulation(update.getSupportedTransitEncapsulation()); switchProperties.setServer42FlowRtt(update.isServer42FlowRtt()); switchProperties.setServer42Port(update.getServer42Port()); switchProperties.setServer42Vlan(update.getServer42Vlan()); switchProperties.setServer42MacAddress(update.getServer42MacAddress()); return new UpdateSwitchPropertiesResult( SwitchPropertiesMapper.INSTANCE.map(switchProperties), isSwitchSyncNeeded); }); if (result.isSwitchSyncRequired()) { carrier.requestSwitchSync(switchId); } if (switchPropertiesDto.isServer42FlowRtt()) { carrier.enableServer42FlowRttOnSwitch(switchId); } else { carrier.disableServer42FlowRttOnSwitch(switchId); } return result.switchPropertiesDto; } }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto) { if (isEmpty(switchPropertiesDto.getSupportedTransitEncapsulation())) { throw new IllegalSwitchPropertiesException("Supported transit encapsulations should not be null or empty"); } SwitchProperties update = SwitchPropertiesMapper.INSTANCE.map(switchPropertiesDto); UpdateSwitchPropertiesResult result = transactionManager.doInTransaction(() -> { SwitchProperties switchProperties = switchPropertiesRepository.findBySwitchId(switchId) .orElseThrow(() -> new SwitchPropertiesNotFoundException(switchId)); validateSwitchProperties(switchId, update); final boolean isSwitchSyncNeeded = isSwitchSyncNeeded(switchProperties, update); switchProperties.setMultiTable(update.isMultiTable()); switchProperties.setSwitchLldp(update.isSwitchLldp()); switchProperties.setSwitchArp(update.isSwitchArp()); switchProperties.setSupportedTransitEncapsulation(update.getSupportedTransitEncapsulation()); switchProperties.setServer42FlowRtt(update.isServer42FlowRtt()); switchProperties.setServer42Port(update.getServer42Port()); switchProperties.setServer42Vlan(update.getServer42Vlan()); switchProperties.setServer42MacAddress(update.getServer42MacAddress()); return new UpdateSwitchPropertiesResult( SwitchPropertiesMapper.INSTANCE.map(switchProperties), isSwitchSyncNeeded); }); if (result.isSwitchSyncRequired()) { carrier.requestSwitchSync(switchId); } if (switchPropertiesDto.isServer42FlowRtt()) { carrier.enableServer42FlowRttOnSwitch(switchId); } else { carrier.disableServer42FlowRttOnSwitch(switchId); } return result.switchPropertiesDto; } SwitchOperationsService(RepositoryFactory repositoryFactory,
TransactionManager transactionManager,
SwitchOperationsServiceCarrier carrier); }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto) { if (isEmpty(switchPropertiesDto.getSupportedTransitEncapsulation())) { throw new IllegalSwitchPropertiesException("Supported transit encapsulations should not be null or empty"); } SwitchProperties update = SwitchPropertiesMapper.INSTANCE.map(switchPropertiesDto); UpdateSwitchPropertiesResult result = transactionManager.doInTransaction(() -> { SwitchProperties switchProperties = switchPropertiesRepository.findBySwitchId(switchId) .orElseThrow(() -> new SwitchPropertiesNotFoundException(switchId)); validateSwitchProperties(switchId, update); final boolean isSwitchSyncNeeded = isSwitchSyncNeeded(switchProperties, update); switchProperties.setMultiTable(update.isMultiTable()); switchProperties.setSwitchLldp(update.isSwitchLldp()); switchProperties.setSwitchArp(update.isSwitchArp()); switchProperties.setSupportedTransitEncapsulation(update.getSupportedTransitEncapsulation()); switchProperties.setServer42FlowRtt(update.isServer42FlowRtt()); switchProperties.setServer42Port(update.getServer42Port()); switchProperties.setServer42Vlan(update.getServer42Vlan()); switchProperties.setServer42MacAddress(update.getServer42MacAddress()); return new UpdateSwitchPropertiesResult( SwitchPropertiesMapper.INSTANCE.map(switchProperties), isSwitchSyncNeeded); }); if (result.isSwitchSyncRequired()) { carrier.requestSwitchSync(switchId); } if (switchPropertiesDto.isServer42FlowRtt()) { carrier.enableServer42FlowRttOnSwitch(switchId); } else { carrier.disableServer42FlowRttOnSwitch(switchId); } return result.switchPropertiesDto; } SwitchOperationsService(RepositoryFactory repositoryFactory,
TransactionManager transactionManager,
SwitchOperationsServiceCarrier carrier); GetSwitchResponse getSwitch(SwitchId switchId); List<GetSwitchResponse> getAllSwitches(); Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance); boolean deleteSwitch(SwitchId switchId, boolean force); void checkSwitchIsDeactivated(SwitchId switchId); void checkSwitchHasNoFlows(SwitchId switchId); void checkSwitchHasNoFlowSegments(SwitchId switchId); void checkSwitchHasNoIsls(SwitchId switchId); SwitchPropertiesDto getSwitchProperties(SwitchId switchId); SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto); PortProperties getPortProperties(SwitchId switchId, int port); Collection<SwitchConnectedDevice> getSwitchConnectedDevices(
SwitchId switchId); List<IslEndpoint> getSwitchIslEndpoints(SwitchId switchId); Switch patchSwitch(SwitchId switchId, SwitchPatch data); }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto) { if (isEmpty(switchPropertiesDto.getSupportedTransitEncapsulation())) { throw new IllegalSwitchPropertiesException("Supported transit encapsulations should not be null or empty"); } SwitchProperties update = SwitchPropertiesMapper.INSTANCE.map(switchPropertiesDto); UpdateSwitchPropertiesResult result = transactionManager.doInTransaction(() -> { SwitchProperties switchProperties = switchPropertiesRepository.findBySwitchId(switchId) .orElseThrow(() -> new SwitchPropertiesNotFoundException(switchId)); validateSwitchProperties(switchId, update); final boolean isSwitchSyncNeeded = isSwitchSyncNeeded(switchProperties, update); switchProperties.setMultiTable(update.isMultiTable()); switchProperties.setSwitchLldp(update.isSwitchLldp()); switchProperties.setSwitchArp(update.isSwitchArp()); switchProperties.setSupportedTransitEncapsulation(update.getSupportedTransitEncapsulation()); switchProperties.setServer42FlowRtt(update.isServer42FlowRtt()); switchProperties.setServer42Port(update.getServer42Port()); switchProperties.setServer42Vlan(update.getServer42Vlan()); switchProperties.setServer42MacAddress(update.getServer42MacAddress()); return new UpdateSwitchPropertiesResult( SwitchPropertiesMapper.INSTANCE.map(switchProperties), isSwitchSyncNeeded); }); if (result.isSwitchSyncRequired()) { carrier.requestSwitchSync(switchId); } if (switchPropertiesDto.isServer42FlowRtt()) { carrier.enableServer42FlowRttOnSwitch(switchId); } else { carrier.disableServer42FlowRttOnSwitch(switchId); } return result.switchPropertiesDto; } SwitchOperationsService(RepositoryFactory repositoryFactory,
TransactionManager transactionManager,
SwitchOperationsServiceCarrier carrier); GetSwitchResponse getSwitch(SwitchId switchId); List<GetSwitchResponse> getAllSwitches(); Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance); boolean deleteSwitch(SwitchId switchId, boolean force); void checkSwitchIsDeactivated(SwitchId switchId); void checkSwitchHasNoFlows(SwitchId switchId); void checkSwitchHasNoFlowSegments(SwitchId switchId); void checkSwitchHasNoIsls(SwitchId switchId); SwitchPropertiesDto getSwitchProperties(SwitchId switchId); SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto); PortProperties getPortProperties(SwitchId switchId, int port); Collection<SwitchConnectedDevice> getSwitchConnectedDevices(
SwitchId switchId); List<IslEndpoint> getSwitchIslEndpoints(SwitchId switchId); Switch patchSwitch(SwitchId switchId, SwitchPatch data); }
|
@Test public void handleOneWayIslLatencyTest() { assertTrue(islLatencyService.isUpdateRequired(FORWARD_ISL_KEY)); islLatencyService.handleOneWayIslLatency(createForwardOneWayLatency(1), System.currentTimeMillis()); assertForwardLatency(1); assertFalse(islLatencyService.isUpdateRequired(FORWARD_ISL_KEY)); islLatencyService.handleOneWayIslLatency(createForwardOneWayLatency(10000), System.currentTimeMillis()); assertForwardLatency(1); assertFalse(islLatencyService.isUpdateRequired(FORWARD_ISL_KEY)); }
|
public void handleOneWayIslLatency(IslOneWayLatency data, long timestamp) { log.debug("Received one way latency {} for ISL {}_{} ===> {}_{}, Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), data.getDstSwitchId(), data.getDstPortNo(), data.getPacketId()); IslKey islKey = new IslKey(data); oneWayLatencyStorage.putIfAbsent(islKey, new LinkedList<>()); oneWayLatencyStorage.get(islKey).add(new LatencyRecord(data.getLatency(), timestamp)); if (isUpdateRequired(islKey)) { updateOneWayLatencyIfNeeded(data, islKey); } }
|
IslLatencyService { public void handleOneWayIslLatency(IslOneWayLatency data, long timestamp) { log.debug("Received one way latency {} for ISL {}_{} ===> {}_{}, Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), data.getDstSwitchId(), data.getDstPortNo(), data.getPacketId()); IslKey islKey = new IslKey(data); oneWayLatencyStorage.putIfAbsent(islKey, new LinkedList<>()); oneWayLatencyStorage.get(islKey).add(new LatencyRecord(data.getLatency(), timestamp)); if (isUpdateRequired(islKey)) { updateOneWayLatencyIfNeeded(data, islKey); } } }
|
IslLatencyService { public void handleOneWayIslLatency(IslOneWayLatency data, long timestamp) { log.debug("Received one way latency {} for ISL {}_{} ===> {}_{}, Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), data.getDstSwitchId(), data.getDstPortNo(), data.getPacketId()); IslKey islKey = new IslKey(data); oneWayLatencyStorage.putIfAbsent(islKey, new LinkedList<>()); oneWayLatencyStorage.get(islKey).add(new LatencyRecord(data.getLatency(), timestamp)); if (isUpdateRequired(islKey)) { updateOneWayLatencyIfNeeded(data, islKey); } } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); }
|
IslLatencyService { public void handleOneWayIslLatency(IslOneWayLatency data, long timestamp) { log.debug("Received one way latency {} for ISL {}_{} ===> {}_{}, Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), data.getDstSwitchId(), data.getDstPortNo(), data.getPacketId()); IslKey islKey = new IslKey(data); oneWayLatencyStorage.putIfAbsent(islKey, new LinkedList<>()); oneWayLatencyStorage.get(islKey).add(new LatencyRecord(data.getLatency(), timestamp)); if (isUpdateRequired(islKey)) { updateOneWayLatencyIfNeeded(data, islKey); } } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); }
|
IslLatencyService { public void handleOneWayIslLatency(IslOneWayLatency data, long timestamp) { log.debug("Received one way latency {} for ISL {}_{} ===> {}_{}, Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), data.getDstSwitchId(), data.getDstPortNo(), data.getPacketId()); IslKey islKey = new IslKey(data); oneWayLatencyStorage.putIfAbsent(islKey, new LinkedList<>()); oneWayLatencyStorage.get(islKey).add(new LatencyRecord(data.getLatency(), timestamp)); if (isUpdateRequired(islKey)) { updateOneWayLatencyIfNeeded(data, islKey); } } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); static final String ONE_WAY_LATENCY; static final String ROUND_TRIP_LATENCY; }
|
@Test public void handleRoundTripIslLatencyTest() { assertTrue(islLatencyService.isUpdateRequired(FORWARD_ISL_KEY)); islLatencyService.handleRoundTripIslLatency( createForwardRoundTripLatency(5), FORWARD_DESTINATION, System.currentTimeMillis()); assertForwardLatency(5); assertFalse(islLatencyService.isUpdateRequired(FORWARD_ISL_KEY)); islLatencyService.handleRoundTripIslLatency( createForwardRoundTripLatency(50000), FORWARD_DESTINATION, System.currentTimeMillis()); assertForwardLatency(5); assertFalse(islLatencyService.isUpdateRequired(FORWARD_ISL_KEY)); }
|
public void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp) { if (data.getLatency() < 0) { log.warn("Received invalid round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId()); return; } log.debug("Received round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId()); IslKey islKey = new IslKey(data, destination); roundTripLatencyStorage.putIfAbsent(islKey, new LinkedList<>()); roundTripLatencyStorage.get(islKey).add(new LatencyRecord(data.getLatency(), timestamp)); if (isUpdateRequired(islKey) || !roundTripLatencyIsSet.contains(islKey)) { updateRoundTripLatency(data, destination, islKey); } }
|
IslLatencyService { public void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp) { if (data.getLatency() < 0) { log.warn("Received invalid round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId()); return; } log.debug("Received round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId()); IslKey islKey = new IslKey(data, destination); roundTripLatencyStorage.putIfAbsent(islKey, new LinkedList<>()); roundTripLatencyStorage.get(islKey).add(new LatencyRecord(data.getLatency(), timestamp)); if (isUpdateRequired(islKey) || !roundTripLatencyIsSet.contains(islKey)) { updateRoundTripLatency(data, destination, islKey); } } }
|
IslLatencyService { public void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp) { if (data.getLatency() < 0) { log.warn("Received invalid round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId()); return; } log.debug("Received round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId()); IslKey islKey = new IslKey(data, destination); roundTripLatencyStorage.putIfAbsent(islKey, new LinkedList<>()); roundTripLatencyStorage.get(islKey).add(new LatencyRecord(data.getLatency(), timestamp)); if (isUpdateRequired(islKey) || !roundTripLatencyIsSet.contains(islKey)) { updateRoundTripLatency(data, destination, islKey); } } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); }
|
IslLatencyService { public void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp) { if (data.getLatency() < 0) { log.warn("Received invalid round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId()); return; } log.debug("Received round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId()); IslKey islKey = new IslKey(data, destination); roundTripLatencyStorage.putIfAbsent(islKey, new LinkedList<>()); roundTripLatencyStorage.get(islKey).add(new LatencyRecord(data.getLatency(), timestamp)); if (isUpdateRequired(islKey) || !roundTripLatencyIsSet.contains(islKey)) { updateRoundTripLatency(data, destination, islKey); } } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); }
|
IslLatencyService { public void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp) { if (data.getLatency() < 0) { log.warn("Received invalid round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId()); return; } log.debug("Received round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId()); IslKey islKey = new IslKey(data, destination); roundTripLatencyStorage.putIfAbsent(islKey, new LinkedList<>()); roundTripLatencyStorage.get(islKey).add(new LatencyRecord(data.getLatency(), timestamp)); if (isUpdateRequired(islKey) || !roundTripLatencyIsSet.contains(islKey)) { updateRoundTripLatency(data, destination, islKey); } } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); static final String ONE_WAY_LATENCY; static final String ROUND_TRIP_LATENCY; }
|
@Test public void isUpdateRequiredTest() { assertTrue(islLatencyService.isUpdateRequired(FORWARD_ISL_KEY)); IslRoundTripLatency data = new IslRoundTripLatency(SWITCH_ID_1, PORT_1, 1L, 0L); Endpoint destination = Endpoint.of(SWITCH_ID_2, PORT_2); islLatencyService.handleRoundTripIslLatency(data, destination, System.currentTimeMillis()); assertFalse(islLatencyService.isUpdateRequired(FORWARD_ISL_KEY)); }
|
@VisibleForTesting boolean isUpdateRequired(IslKey islKey) { return Instant.now().isAfter(nextUpdateTimeMap.getOrDefault(islKey, Instant.MIN)); }
|
IslLatencyService { @VisibleForTesting boolean isUpdateRequired(IslKey islKey) { return Instant.now().isAfter(nextUpdateTimeMap.getOrDefault(islKey, Instant.MIN)); } }
|
IslLatencyService { @VisibleForTesting boolean isUpdateRequired(IslKey islKey) { return Instant.now().isAfter(nextUpdateTimeMap.getOrDefault(islKey, Instant.MIN)); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); }
|
IslLatencyService { @VisibleForTesting boolean isUpdateRequired(IslKey islKey) { return Instant.now().isAfter(nextUpdateTimeMap.getOrDefault(islKey, Instant.MIN)); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); }
|
IslLatencyService { @VisibleForTesting boolean isUpdateRequired(IslKey islKey) { return Instant.now().isAfter(nextUpdateTimeMap.getOrDefault(islKey, Instant.MIN)); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); static final String ONE_WAY_LATENCY; static final String ROUND_TRIP_LATENCY; }
|
@Test public void getNextUpdateTimeTest() { Instant actualTime = islLatencyService.getNextUpdateTime(); long expectedTime = System.currentTimeMillis() + LATENCY_UPDATE_INTERVAL * 1000; assertEquals(expectedTime, actualTime.toEpochMilli(), 50); }
|
@VisibleForTesting Instant getNextUpdateTime() { return Instant.now().plusSeconds(latencyUpdateInterval); }
|
IslLatencyService { @VisibleForTesting Instant getNextUpdateTime() { return Instant.now().plusSeconds(latencyUpdateInterval); } }
|
IslLatencyService { @VisibleForTesting Instant getNextUpdateTime() { return Instant.now().plusSeconds(latencyUpdateInterval); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); }
|
IslLatencyService { @VisibleForTesting Instant getNextUpdateTime() { return Instant.now().plusSeconds(latencyUpdateInterval); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); }
|
IslLatencyService { @VisibleForTesting Instant getNextUpdateTime() { return Instant.now().plusSeconds(latencyUpdateInterval); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); static final String ONE_WAY_LATENCY; static final String ROUND_TRIP_LATENCY; }
|
@Test public void calculateAverageLatencyTest() { Queue<LatencyRecord> latencyRecords = new LinkedList<>(); for (int i = 1; i <= 5; i++) { latencyRecords.add(new LatencyRecord(i, 1)); } assertEquals(3, islLatencyService.calculateAverageLatency(latencyRecords)); }
|
@VisibleForTesting long calculateAverageLatency(Queue<LatencyRecord> recordsQueue) { if (recordsQueue.isEmpty()) { log.error("Couldn't calculate average latency. Records queue is empty"); return -1; } long sum = 0; for (LatencyRecord record : recordsQueue) { sum += record.getLatency(); } return sum / recordsQueue.size(); }
|
IslLatencyService { @VisibleForTesting long calculateAverageLatency(Queue<LatencyRecord> recordsQueue) { if (recordsQueue.isEmpty()) { log.error("Couldn't calculate average latency. Records queue is empty"); return -1; } long sum = 0; for (LatencyRecord record : recordsQueue) { sum += record.getLatency(); } return sum / recordsQueue.size(); } }
|
IslLatencyService { @VisibleForTesting long calculateAverageLatency(Queue<LatencyRecord> recordsQueue) { if (recordsQueue.isEmpty()) { log.error("Couldn't calculate average latency. Records queue is empty"); return -1; } long sum = 0; for (LatencyRecord record : recordsQueue) { sum += record.getLatency(); } return sum / recordsQueue.size(); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); }
|
IslLatencyService { @VisibleForTesting long calculateAverageLatency(Queue<LatencyRecord> recordsQueue) { if (recordsQueue.isEmpty()) { log.error("Couldn't calculate average latency. Records queue is empty"); return -1; } long sum = 0; for (LatencyRecord record : recordsQueue) { sum += record.getLatency(); } return sum / recordsQueue.size(); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); }
|
IslLatencyService { @VisibleForTesting long calculateAverageLatency(Queue<LatencyRecord> recordsQueue) { if (recordsQueue.isEmpty()) { log.error("Couldn't calculate average latency. Records queue is empty"); return -1; } long sum = 0; for (LatencyRecord record : recordsQueue) { sum += record.getLatency(); } return sum / recordsQueue.size(); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); static final String ONE_WAY_LATENCY; static final String ROUND_TRIP_LATENCY; }
|
@Test public void calculateAverageLatencyEmptyTest() { assertEquals(-1, islLatencyService.calculateAverageLatency(new LinkedList<>())); }
|
@VisibleForTesting long calculateAverageLatency(Queue<LatencyRecord> recordsQueue) { if (recordsQueue.isEmpty()) { log.error("Couldn't calculate average latency. Records queue is empty"); return -1; } long sum = 0; for (LatencyRecord record : recordsQueue) { sum += record.getLatency(); } return sum / recordsQueue.size(); }
|
IslLatencyService { @VisibleForTesting long calculateAverageLatency(Queue<LatencyRecord> recordsQueue) { if (recordsQueue.isEmpty()) { log.error("Couldn't calculate average latency. Records queue is empty"); return -1; } long sum = 0; for (LatencyRecord record : recordsQueue) { sum += record.getLatency(); } return sum / recordsQueue.size(); } }
|
IslLatencyService { @VisibleForTesting long calculateAverageLatency(Queue<LatencyRecord> recordsQueue) { if (recordsQueue.isEmpty()) { log.error("Couldn't calculate average latency. Records queue is empty"); return -1; } long sum = 0; for (LatencyRecord record : recordsQueue) { sum += record.getLatency(); } return sum / recordsQueue.size(); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); }
|
IslLatencyService { @VisibleForTesting long calculateAverageLatency(Queue<LatencyRecord> recordsQueue) { if (recordsQueue.isEmpty()) { log.error("Couldn't calculate average latency. Records queue is empty"); return -1; } long sum = 0; for (LatencyRecord record : recordsQueue) { sum += record.getLatency(); } return sum / recordsQueue.size(); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); }
|
IslLatencyService { @VisibleForTesting long calculateAverageLatency(Queue<LatencyRecord> recordsQueue) { if (recordsQueue.isEmpty()) { log.error("Couldn't calculate average latency. Records queue is empty"); return -1; } long sum = 0; for (LatencyRecord record : recordsQueue) { sum += record.getLatency(); } return sum / recordsQueue.size(); } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); static final String ONE_WAY_LATENCY; static final String ROUND_TRIP_LATENCY; }
|
@Test public void pollExpiredRecordsTest() { Instant time = Instant.now().minusSeconds(LATENCY_UPDATE_TIME_RANGE * 2); Queue<LatencyRecord> latencyRecords = new LinkedList<>(); for (int i = 0; i < 5; i++) { latencyRecords.add(new LatencyRecord(i, time.toEpochMilli())); time = time.plusSeconds(1); } time = Instant.now().minusSeconds(LATENCY_UPDATE_TIME_RANGE - 7); for (int i = 5; i < 10; i++) { latencyRecords.add(new LatencyRecord(i, time.toEpochMilli())); time = time.plusSeconds(1); } assertEquals(10, latencyRecords.size()); islLatencyService.pollExpiredRecords(latencyRecords); assertEquals(5, latencyRecords.size()); for (int i = 5; i < 10; i++) { assertEquals(i, latencyRecords.poll().getLatency()); } }
|
@VisibleForTesting void pollExpiredRecords(Queue<LatencyRecord> recordsQueue) { if (recordsQueue == null) { return; } Instant oldestTimeInRange = Instant.now().minusSeconds(latencyUpdateTimeRange); while (!recordsQueue.isEmpty() && Instant.ofEpochMilli(recordsQueue.peek().getTimestamp()).isBefore(oldestTimeInRange)) { recordsQueue.poll(); } }
|
IslLatencyService { @VisibleForTesting void pollExpiredRecords(Queue<LatencyRecord> recordsQueue) { if (recordsQueue == null) { return; } Instant oldestTimeInRange = Instant.now().minusSeconds(latencyUpdateTimeRange); while (!recordsQueue.isEmpty() && Instant.ofEpochMilli(recordsQueue.peek().getTimestamp()).isBefore(oldestTimeInRange)) { recordsQueue.poll(); } } }
|
IslLatencyService { @VisibleForTesting void pollExpiredRecords(Queue<LatencyRecord> recordsQueue) { if (recordsQueue == null) { return; } Instant oldestTimeInRange = Instant.now().minusSeconds(latencyUpdateTimeRange); while (!recordsQueue.isEmpty() && Instant.ofEpochMilli(recordsQueue.peek().getTimestamp()).isBefore(oldestTimeInRange)) { recordsQueue.poll(); } } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); }
|
IslLatencyService { @VisibleForTesting void pollExpiredRecords(Queue<LatencyRecord> recordsQueue) { if (recordsQueue == null) { return; } Instant oldestTimeInRange = Instant.now().minusSeconds(latencyUpdateTimeRange); while (!recordsQueue.isEmpty() && Instant.ofEpochMilli(recordsQueue.peek().getTimestamp()).isBefore(oldestTimeInRange)) { recordsQueue.poll(); } } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); }
|
IslLatencyService { @VisibleForTesting void pollExpiredRecords(Queue<LatencyRecord> recordsQueue) { if (recordsQueue == null) { return; } Instant oldestTimeInRange = Instant.now().minusSeconds(latencyUpdateTimeRange); while (!recordsQueue.isEmpty() && Instant.ofEpochMilli(recordsQueue.peek().getTimestamp()).isBefore(oldestTimeInRange)) { recordsQueue.poll(); } } IslLatencyService(TransactionManager transactionManager,
RepositoryFactory repositoryFactory, long latencyUpdateInterval,
long latencyUpdateTimeRange); void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp); void handleOneWayIslLatency(IslOneWayLatency data, long timestamp); static final String ONE_WAY_LATENCY; static final String ROUND_TRIP_LATENCY; }
|
@Test public void testGetFlowHistory() throws Exception { try { mockMvc.perform(get("/api/flows/all/history/{flowId}", TestFlowMock.FLOW_ID) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); assertTrue(true); } catch (Exception exception) { assertTrue(false); } }
|
@RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
@Test public void testGetFlowHistoryIfRequestParamsPassed() throws Exception { List<FlowHistory> flowHistories = new ArrayList<FlowHistory>(); try { when(flowController.getFlowHistory(TestFlowMock.FLOW_ID, TestFlowMock.TIME_FROM, TestFlowMock.TIME_TO)) .thenReturn(flowHistories); mockMvc.perform(get("/api/flows/all/history/{flowId}", TestFlowMock.FLOW_ID) .param("timeFrom", TestFlowMock.TIME_TO) .param("timeTo", TestFlowMock.TIME_TO) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); assertTrue(true); } catch (Exception exception) { assertTrue(false); } }
|
@RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
@Test public void testGetFlowsHistoryIfFlowIdNotPassed() throws Exception { List<FlowHistory> flowHistories = new ArrayList<FlowHistory>(); try { when(flowController.getFlowHistory(TestFlowMock.FLOW_ID_NULL, TestFlowMock.TIME_FROM, TestFlowMock.TIME_TO)) .thenReturn(flowHistories); mockMvc.perform(get("/api/flows/all/history/{flowId}", TestFlowMock.FLOW_ID_NULL) .param("timeFrom", TestFlowMock.TIME_FROM) .param("timeTo", TestFlowMock.TIME_TO) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isNotFound()); assertTrue(true); } catch (Exception exception) { assertTrue(false); } }
|
@RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
FlowController extends BaseController { @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) public @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId, @RequestParam(name = "timeFrom", required = false) String timeFrom, @RequestParam(name = "timeTo", required = false) String timeTo) { return flowService.getFlowHistory(flowId, timeFrom, timeTo); } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
@Test public void errorReporting() throws Exception { final ExecutionException error = new ExecutionException("Emulate kafka send error", new IOException()); Future promise = mock(Future.class); expect(promise.get()).andThrow(error).anyTimes(); replay(promise); expect(kafkaProducer.send(anyObject(), anyObject(Callback.class))) .andAnswer(new IAnswer<Future<RecordMetadata>>() { @Override public Future<RecordMetadata> answer() { Callback callback = (Callback) getCurrentArguments()[1]; callback.onCompletion(null, error); return promise; } }); replay(kafkaProducer); subject.sendMessageAndTrack(TOPIC, makePayload()); verify(kafkaProducer); }
|
public void sendMessageAndTrack(String topic, Message message) { produce(encode(topic, message), new SendStatusCallback(this, topic, message)); }
|
KafkaProducerService implements IKafkaProducerService { public void sendMessageAndTrack(String topic, Message message) { produce(encode(topic, message), new SendStatusCallback(this, topic, message)); } }
|
KafkaProducerService implements IKafkaProducerService { public void sendMessageAndTrack(String topic, Message message) { produce(encode(topic, message), new SendStatusCallback(this, topic, message)); } }
|
KafkaProducerService implements IKafkaProducerService { public void sendMessageAndTrack(String topic, Message message) { produce(encode(topic, message), new SendStatusCallback(this, topic, message)); } @Override void setup(FloodlightModuleContext moduleContext); void sendMessageAndTrack(String topic, Message message); void sendMessageAndTrack(String topic, String key, Message message); @Override void sendMessageAndTrack(String topic, String key, AbstractMessage message); SendStatus sendMessage(String topic, Message message); int getFailedSendMessageCounter(); }
|
KafkaProducerService implements IKafkaProducerService { public void sendMessageAndTrack(String topic, Message message) { produce(encode(topic, message), new SendStatusCallback(this, topic, message)); } @Override void setup(FloodlightModuleContext moduleContext); void sendMessageAndTrack(String topic, Message message); void sendMessageAndTrack(String topic, String key, Message message); @Override void sendMessageAndTrack(String topic, String key, AbstractMessage message); SendStatus sendMessage(String topic, Message message); int getFailedSendMessageCounter(); }
|
@Test public void testGetFlowById() throws Exception { FlowInfo flowInfo = new FlowInfo(); try { when(flowService.getFlowById(TestFlowMock.FLOW_ID, TestFlowMock.CONTROLLER_FLAG)).thenReturn(flowInfo); mockMvc.perform(get("/api/flows/{flowId}", TestFlowMock.FLOW_ID).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); assertTrue(true); } catch (Exception e) { assertTrue(false); } }
|
@RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) public @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) { LOGGER.info("Get flow by id. Flow id: '" + flowId + "'"); FlowInfo flowInfo = flowService.getFlowById(flowId, controller); return flowInfo; }
|
FlowController extends BaseController { @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) public @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) { LOGGER.info("Get flow by id. Flow id: '" + flowId + "'"); FlowInfo flowInfo = flowService.getFlowById(flowId, controller); return flowInfo; } }
|
FlowController extends BaseController { @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) public @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) { LOGGER.info("Get flow by id. Flow id: '" + flowId + "'"); FlowInfo flowInfo = flowService.getFlowById(flowId, controller); return flowInfo; } }
|
FlowController extends BaseController { @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) public @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) { LOGGER.info("Get flow by id. Flow id: '" + flowId + "'"); FlowInfo flowInfo = flowService.getFlowById(flowId, controller); return flowInfo; } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
FlowController extends BaseController { @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) public @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) { LOGGER.info("Get flow by id. Flow id: '" + flowId + "'"); FlowInfo flowInfo = flowService.getFlowById(flowId, controller); return flowInfo; } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
@Test public void testGetFlowByIdWhenFlowIdNotPassed() throws Exception { FlowInfo flowInfo = new FlowInfo(); try { when(flowService.getFlowById(TestFlowMock.FLOW_ID_NULL, TestFlowMock.CONTROLLER_FLAG)).thenReturn(flowInfo); mockMvc.perform(get("/api/flows/{flowId}", TestFlowMock.FLOW_ID_NULL, true) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isMethodNotAllowed()); assertTrue(true); } catch (Exception e) { assertTrue(false); } }
|
@RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) public @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) { LOGGER.info("Get flow by id. Flow id: '" + flowId + "'"); FlowInfo flowInfo = flowService.getFlowById(flowId, controller); return flowInfo; }
|
FlowController extends BaseController { @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) public @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) { LOGGER.info("Get flow by id. Flow id: '" + flowId + "'"); FlowInfo flowInfo = flowService.getFlowById(flowId, controller); return flowInfo; } }
|
FlowController extends BaseController { @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) public @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) { LOGGER.info("Get flow by id. Flow id: '" + flowId + "'"); FlowInfo flowInfo = flowService.getFlowById(flowId, controller); return flowInfo; } }
|
FlowController extends BaseController { @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) public @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) { LOGGER.info("Get flow by id. Flow id: '" + flowId + "'"); FlowInfo flowInfo = flowService.getFlowById(flowId, controller); return flowInfo; } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
FlowController extends BaseController { @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) public @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) { LOGGER.info("Get flow by id. Flow id: '" + flowId + "'"); FlowInfo flowInfo = flowService.getFlowById(flowId, controller); return flowInfo; } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
@Test public void testGetFlowPath() throws Exception { FlowPayload flowPayload = new FlowPayload(); try { when(flowService.getFlowPath(Mockito.anyString())).thenReturn(flowPayload); mockMvc.perform(get("/api/flows/path/{flowId}", TestFlowMock.FLOW_ID) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); assertTrue(true); } catch (Exception e) { assertTrue(false); } }
|
@RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId) { LOGGER.info("Get flow path. Flow id: '" + flowId + "'"); return flowService.getFlowPath(flowId); }
|
FlowController extends BaseController { @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId) { LOGGER.info("Get flow path. Flow id: '" + flowId + "'"); return flowService.getFlowPath(flowId); } }
|
FlowController extends BaseController { @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId) { LOGGER.info("Get flow path. Flow id: '" + flowId + "'"); return flowService.getFlowPath(flowId); } }
|
FlowController extends BaseController { @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId) { LOGGER.info("Get flow path. Flow id: '" + flowId + "'"); return flowService.getFlowPath(flowId); } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
FlowController extends BaseController { @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId) { LOGGER.info("Get flow path. Flow id: '" + flowId + "'"); return flowService.getFlowPath(flowId); } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
@Test public void testGetFlowPathWhenFlowIdNotPassed() throws Exception { FlowPayload flowPayload = new FlowPayload(); try { when(flowService.getFlowPath(Mockito.anyString())).thenReturn(flowPayload); mockMvc.perform(get("/api/flows/get/path/{flowId}", TestFlowMock.FLOW_ID_NULL) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isNotFound()); assertTrue(true); } catch (Exception e) { assertTrue(false); } }
|
@RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId) { LOGGER.info("Get flow path. Flow id: '" + flowId + "'"); return flowService.getFlowPath(flowId); }
|
FlowController extends BaseController { @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId) { LOGGER.info("Get flow path. Flow id: '" + flowId + "'"); return flowService.getFlowPath(flowId); } }
|
FlowController extends BaseController { @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId) { LOGGER.info("Get flow path. Flow id: '" + flowId + "'"); return flowService.getFlowPath(flowId); } }
|
FlowController extends BaseController { @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId) { LOGGER.info("Get flow path. Flow id: '" + flowId + "'"); return flowService.getFlowPath(flowId); } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
FlowController extends BaseController { @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId) { LOGGER.info("Get flow path. Flow id: '" + flowId + "'"); return flowService.getFlowPath(flowId); } @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody Collection<FlowCount> getFlowCount(); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody List<FlowInfo> getFlows(
@RequestParam(name = "status", required = false) List<String> statuses,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/path/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPayload getFlowPath(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/reroute", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowPath rerouteFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}/validate", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody String validateFlow(@PathVariable final String flowId); @RequestMapping(value = "/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody FlowInfo getFlowById(@PathVariable final String flowId,
@RequestParam(name = "controller", required = false) boolean controller); @RequestMapping(value = "/{flowId}/status", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowStatus getFlowStatusById(@PathVariable final String flowId); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_CREATE }) @ResponseBody Flow createFlow(@RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.CREATED) @Permissions(values = { IConstants.Permission.FW_FLOW_UPDATE }) @ResponseBody Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/{flowId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_DELETE }) @ResponseBody Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId); @RequestMapping(value = "/{flowId}/sync", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_RESYNC }) @ResponseBody String resyncFlow(@PathVariable final String flowId); @RequestMapping(value = "/status", method = { RequestMethod.GET }) Set<String> getAllStatus(); @Scheduled(fixedDelayString = "${status.cron.time}") void getAllStatusWithCron(); @RequestMapping(value = "/{flowId}/ping", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_PING }) @ResponseBody String flowPing(@PathVariable final String flowId, @RequestBody final Flow flow); @RequestMapping(value = "/all/history/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.FW_FLOW_HISTORY }) @ResponseBody List<FlowHistory> getFlowHistory(@PathVariable final String flowId,
@RequestParam(name = "timeFrom", required = false) String timeFrom,
@RequestParam(name = "timeTo", required = false) String timeTo); @RequestMapping(value = "/connected/devices/{flowId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody FlowConnectedDevice getFlowConnectedDevice(@PathVariable final String flowId,
@RequestParam(name = "since", required = false) String timeLastSeen); }
|
@Test public void testGetAllSwitchFlows() { ResponseEntity<List<?>> responseList = new ResponseEntity<List<?>>(HttpStatus.OK); try { when(serviceSwitch.getPortFlows(TestSwitchMock.SWITCH_ID, TestSwitchMock.PORT, TestFlowMock.CONTROLLER_FLAG)).thenReturn(responseList); mockMvc.perform(get("/api/switch/{switchId}/flows", TestSwitchMock.SWITCH_ID) .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()); assertTrue(true); } catch (Exception e) { assertTrue(false); } }
|
@RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId, @RequestParam(value = "port", required = false) final String port, @RequestParam(value = "inventory", required = false) final boolean inventory) { return serviceSwitch.getPortFlows(switchId, port, inventory); }
|
SwitchController { @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId, @RequestParam(value = "port", required = false) final String port, @RequestParam(value = "inventory", required = false) final boolean inventory) { return serviceSwitch.getPortFlows(switchId, port, inventory); } }
|
SwitchController { @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId, @RequestParam(value = "port", required = false) final String port, @RequestParam(value = "inventory", required = false) final boolean inventory) { return serviceSwitch.getPortFlows(switchId, port, inventory); } }
|
SwitchController { @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId, @RequestParam(value = "port", required = false) final String port, @RequestParam(value = "inventory", required = false) final boolean inventory) { return serviceSwitch.getPortFlows(switchId, port, inventory); } @RequestMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<SwitchInfo> getSwitchesDetail(
@RequestParam(value = "storeConfigurationStatus", required = false)
final boolean storeConfigurationStatus,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody SwitchInfo getSwitchDetail(@PathVariable final String switchId,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/name/{switchId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_UPDATE_NAME}) @ResponseBody SwitchInfo saveOrUpdateSwitchName(@PathVariable final String switchId,
@RequestBody final String switchName); @RequestMapping(value = "/links", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody List<IslLinkInfo> getLinksDetail(@RequestParam(value = "src_switch",
required = false) final String srcSwitch, @RequestParam(value = "src_port",
required = false) final String srcPort, @RequestParam(value = "dst_switch",
required = false) final String dstSwitch, @RequestParam(value = "dst_port",
required = false) final String dstPort); @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto); @RequestMapping(path = "/links/under-maintenance", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_MAINTENANCE}) @ResponseBody List<IslLinkInfo> updateLinkUnderMaintenance(
@RequestBody final LinkUnderMaintenanceDto linkUnderMaintenanceDto); @RequestMapping(path = "/link/props", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody LinkProps getLinkProps(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort); @RequestMapping(path = "/link/bandwidth", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BANDWIDTH}) @ResponseBody LinkMaxBandwidth updateMaxBandwidth(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort,
@RequestBody LinkMaxBandwidth linkMaxBandwidth); @RequestMapping(path = "/link/enable-bfd", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BFD_FLAG}) @ResponseBody List<IslLinkInfo> updateEnableBfdFlag(@RequestBody LinkParametersDto linkParametersDto); @RequestMapping(path = "/link/props", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody String updateLinkProps(@RequestBody final List<LinkProps> keys); @RequestMapping(path = "/{switchId}/rules", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PERMISSION_RULES}) @ResponseBody String getSwitchRules(@PathVariable final String switchId); @RequestMapping(path = "/{switchId}/{port}/config", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PORT_CONFIG}) @ResponseBody ConfiguredPort configureSwitchPort(
@RequestBody final PortConfiguration configuration,
@PathVariable final String switchId, @PathVariable final String port); @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId,
@RequestParam(value = "port", required = false) final String port,
@RequestParam(value = "inventory", required = false) final boolean inventory); @RequestMapping(value = "/links/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<FlowInfo> getIslFlows(@RequestParam(name = "src_switch",
required = true) final String srcSwitch, @RequestParam(name = "src_port",
required = true) final String srcPort, @RequestParam(name = "dst_switch",
required = true) final String dstSwitch, @RequestParam(name = "dst_port",
required = true) final String dstPort); @RequestMapping(value = "/meters/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_METERS}) @ResponseBody SwitchMeter getSwitchMeters(@PathVariable final String switchId); @RequestMapping(value = "/under-maintenance/{switchId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_MAINTENANCE}) @ResponseBody SwitchInfo updateSwitchMaintenanceStatus(
@PathVariable("switchId") final String switchId,
@RequestBody final SwitchInfo switchInfo); @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId,
@RequestParam(name = "force", required = false) boolean force); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port, @RequestBody SwitchProperty switchProperty); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port); }
|
SwitchController { @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId, @RequestParam(value = "port", required = false) final String port, @RequestParam(value = "inventory", required = false) final boolean inventory) { return serviceSwitch.getPortFlows(switchId, port, inventory); } @RequestMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<SwitchInfo> getSwitchesDetail(
@RequestParam(value = "storeConfigurationStatus", required = false)
final boolean storeConfigurationStatus,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody SwitchInfo getSwitchDetail(@PathVariable final String switchId,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/name/{switchId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_UPDATE_NAME}) @ResponseBody SwitchInfo saveOrUpdateSwitchName(@PathVariable final String switchId,
@RequestBody final String switchName); @RequestMapping(value = "/links", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody List<IslLinkInfo> getLinksDetail(@RequestParam(value = "src_switch",
required = false) final String srcSwitch, @RequestParam(value = "src_port",
required = false) final String srcPort, @RequestParam(value = "dst_switch",
required = false) final String dstSwitch, @RequestParam(value = "dst_port",
required = false) final String dstPort); @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto); @RequestMapping(path = "/links/under-maintenance", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_MAINTENANCE}) @ResponseBody List<IslLinkInfo> updateLinkUnderMaintenance(
@RequestBody final LinkUnderMaintenanceDto linkUnderMaintenanceDto); @RequestMapping(path = "/link/props", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody LinkProps getLinkProps(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort); @RequestMapping(path = "/link/bandwidth", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BANDWIDTH}) @ResponseBody LinkMaxBandwidth updateMaxBandwidth(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort,
@RequestBody LinkMaxBandwidth linkMaxBandwidth); @RequestMapping(path = "/link/enable-bfd", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BFD_FLAG}) @ResponseBody List<IslLinkInfo> updateEnableBfdFlag(@RequestBody LinkParametersDto linkParametersDto); @RequestMapping(path = "/link/props", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody String updateLinkProps(@RequestBody final List<LinkProps> keys); @RequestMapping(path = "/{switchId}/rules", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PERMISSION_RULES}) @ResponseBody String getSwitchRules(@PathVariable final String switchId); @RequestMapping(path = "/{switchId}/{port}/config", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PORT_CONFIG}) @ResponseBody ConfiguredPort configureSwitchPort(
@RequestBody final PortConfiguration configuration,
@PathVariable final String switchId, @PathVariable final String port); @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId,
@RequestParam(value = "port", required = false) final String port,
@RequestParam(value = "inventory", required = false) final boolean inventory); @RequestMapping(value = "/links/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<FlowInfo> getIslFlows(@RequestParam(name = "src_switch",
required = true) final String srcSwitch, @RequestParam(name = "src_port",
required = true) final String srcPort, @RequestParam(name = "dst_switch",
required = true) final String dstSwitch, @RequestParam(name = "dst_port",
required = true) final String dstPort); @RequestMapping(value = "/meters/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_METERS}) @ResponseBody SwitchMeter getSwitchMeters(@PathVariable final String switchId); @RequestMapping(value = "/under-maintenance/{switchId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_MAINTENANCE}) @ResponseBody SwitchInfo updateSwitchMaintenanceStatus(
@PathVariable("switchId") final String switchId,
@RequestBody final SwitchInfo switchInfo); @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId,
@RequestParam(name = "force", required = false) boolean force); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port, @RequestBody SwitchProperty switchProperty); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port); }
|
@Test public void testDeleteSwitch() { SwitchInfo switcheInfo = new SwitchInfo(); try { when(serviceSwitch.deleteSwitch(TestSwitchMock.SWITCH_ID, false)).thenReturn(switcheInfo); mockMvc.perform(delete("/api/switch/{switchId}", TestSwitchMock.SWITCH_ID, true) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); assertTrue(true); } catch (Exception e) { System.out.println("exception: " + e.getMessage()); assertTrue(false); } }
|
@RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) public @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId, @RequestParam(name = "force", required = false) boolean force) { activityLogger.log(ActivityType.DELETE_SWITCH, switchId); return serviceSwitch.deleteSwitch(switchId, force); }
|
SwitchController { @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) public @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId, @RequestParam(name = "force", required = false) boolean force) { activityLogger.log(ActivityType.DELETE_SWITCH, switchId); return serviceSwitch.deleteSwitch(switchId, force); } }
|
SwitchController { @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) public @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId, @RequestParam(name = "force", required = false) boolean force) { activityLogger.log(ActivityType.DELETE_SWITCH, switchId); return serviceSwitch.deleteSwitch(switchId, force); } }
|
SwitchController { @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) public @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId, @RequestParam(name = "force", required = false) boolean force) { activityLogger.log(ActivityType.DELETE_SWITCH, switchId); return serviceSwitch.deleteSwitch(switchId, force); } @RequestMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<SwitchInfo> getSwitchesDetail(
@RequestParam(value = "storeConfigurationStatus", required = false)
final boolean storeConfigurationStatus,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody SwitchInfo getSwitchDetail(@PathVariable final String switchId,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/name/{switchId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_UPDATE_NAME}) @ResponseBody SwitchInfo saveOrUpdateSwitchName(@PathVariable final String switchId,
@RequestBody final String switchName); @RequestMapping(value = "/links", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody List<IslLinkInfo> getLinksDetail(@RequestParam(value = "src_switch",
required = false) final String srcSwitch, @RequestParam(value = "src_port",
required = false) final String srcPort, @RequestParam(value = "dst_switch",
required = false) final String dstSwitch, @RequestParam(value = "dst_port",
required = false) final String dstPort); @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto); @RequestMapping(path = "/links/under-maintenance", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_MAINTENANCE}) @ResponseBody List<IslLinkInfo> updateLinkUnderMaintenance(
@RequestBody final LinkUnderMaintenanceDto linkUnderMaintenanceDto); @RequestMapping(path = "/link/props", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody LinkProps getLinkProps(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort); @RequestMapping(path = "/link/bandwidth", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BANDWIDTH}) @ResponseBody LinkMaxBandwidth updateMaxBandwidth(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort,
@RequestBody LinkMaxBandwidth linkMaxBandwidth); @RequestMapping(path = "/link/enable-bfd", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BFD_FLAG}) @ResponseBody List<IslLinkInfo> updateEnableBfdFlag(@RequestBody LinkParametersDto linkParametersDto); @RequestMapping(path = "/link/props", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody String updateLinkProps(@RequestBody final List<LinkProps> keys); @RequestMapping(path = "/{switchId}/rules", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PERMISSION_RULES}) @ResponseBody String getSwitchRules(@PathVariable final String switchId); @RequestMapping(path = "/{switchId}/{port}/config", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PORT_CONFIG}) @ResponseBody ConfiguredPort configureSwitchPort(
@RequestBody final PortConfiguration configuration,
@PathVariable final String switchId, @PathVariable final String port); @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId,
@RequestParam(value = "port", required = false) final String port,
@RequestParam(value = "inventory", required = false) final boolean inventory); @RequestMapping(value = "/links/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<FlowInfo> getIslFlows(@RequestParam(name = "src_switch",
required = true) final String srcSwitch, @RequestParam(name = "src_port",
required = true) final String srcPort, @RequestParam(name = "dst_switch",
required = true) final String dstSwitch, @RequestParam(name = "dst_port",
required = true) final String dstPort); @RequestMapping(value = "/meters/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_METERS}) @ResponseBody SwitchMeter getSwitchMeters(@PathVariable final String switchId); @RequestMapping(value = "/under-maintenance/{switchId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_MAINTENANCE}) @ResponseBody SwitchInfo updateSwitchMaintenanceStatus(
@PathVariable("switchId") final String switchId,
@RequestBody final SwitchInfo switchInfo); @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId,
@RequestParam(name = "force", required = false) boolean force); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port, @RequestBody SwitchProperty switchProperty); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port); }
|
SwitchController { @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) public @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId, @RequestParam(name = "force", required = false) boolean force) { activityLogger.log(ActivityType.DELETE_SWITCH, switchId); return serviceSwitch.deleteSwitch(switchId, force); } @RequestMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<SwitchInfo> getSwitchesDetail(
@RequestParam(value = "storeConfigurationStatus", required = false)
final boolean storeConfigurationStatus,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody SwitchInfo getSwitchDetail(@PathVariable final String switchId,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/name/{switchId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_UPDATE_NAME}) @ResponseBody SwitchInfo saveOrUpdateSwitchName(@PathVariable final String switchId,
@RequestBody final String switchName); @RequestMapping(value = "/links", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody List<IslLinkInfo> getLinksDetail(@RequestParam(value = "src_switch",
required = false) final String srcSwitch, @RequestParam(value = "src_port",
required = false) final String srcPort, @RequestParam(value = "dst_switch",
required = false) final String dstSwitch, @RequestParam(value = "dst_port",
required = false) final String dstPort); @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto); @RequestMapping(path = "/links/under-maintenance", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_MAINTENANCE}) @ResponseBody List<IslLinkInfo> updateLinkUnderMaintenance(
@RequestBody final LinkUnderMaintenanceDto linkUnderMaintenanceDto); @RequestMapping(path = "/link/props", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody LinkProps getLinkProps(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort); @RequestMapping(path = "/link/bandwidth", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BANDWIDTH}) @ResponseBody LinkMaxBandwidth updateMaxBandwidth(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort,
@RequestBody LinkMaxBandwidth linkMaxBandwidth); @RequestMapping(path = "/link/enable-bfd", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BFD_FLAG}) @ResponseBody List<IslLinkInfo> updateEnableBfdFlag(@RequestBody LinkParametersDto linkParametersDto); @RequestMapping(path = "/link/props", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody String updateLinkProps(@RequestBody final List<LinkProps> keys); @RequestMapping(path = "/{switchId}/rules", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PERMISSION_RULES}) @ResponseBody String getSwitchRules(@PathVariable final String switchId); @RequestMapping(path = "/{switchId}/{port}/config", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PORT_CONFIG}) @ResponseBody ConfiguredPort configureSwitchPort(
@RequestBody final PortConfiguration configuration,
@PathVariable final String switchId, @PathVariable final String port); @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId,
@RequestParam(value = "port", required = false) final String port,
@RequestParam(value = "inventory", required = false) final boolean inventory); @RequestMapping(value = "/links/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<FlowInfo> getIslFlows(@RequestParam(name = "src_switch",
required = true) final String srcSwitch, @RequestParam(name = "src_port",
required = true) final String srcPort, @RequestParam(name = "dst_switch",
required = true) final String dstSwitch, @RequestParam(name = "dst_port",
required = true) final String dstPort); @RequestMapping(value = "/meters/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_METERS}) @ResponseBody SwitchMeter getSwitchMeters(@PathVariable final String switchId); @RequestMapping(value = "/under-maintenance/{switchId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_MAINTENANCE}) @ResponseBody SwitchInfo updateSwitchMaintenanceStatus(
@PathVariable("switchId") final String switchId,
@RequestBody final SwitchInfo switchInfo); @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId,
@RequestParam(name = "force", required = false) boolean force); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port, @RequestBody SwitchProperty switchProperty); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port); }
|
@Test public void testDeleteIsl() throws Exception { LinkParametersDto linkParametersDto = new LinkParametersDto(); linkParametersDto.setSrcPort(Integer.valueOf(TestIslMock.SRC_PORT)); linkParametersDto.setSrcSwitch(TestIslMock.SRC_SWITCH); linkParametersDto.setDstPort(Integer.valueOf(TestIslMock.DST_PORT)); linkParametersDto.setDstSwitch(TestIslMock.DST_SWITCH); List<IslLinkInfo> islLinkInfo = new ArrayList<IslLinkInfo>(); String inputJson = mapToJson(linkParametersDto); when(serviceSwitch.deleteLink(linkParametersDto, TestIslMock.USER_ID)).thenReturn(islLinkInfo); MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders .delete("/api/switch/links") .content(inputJson) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andReturn(); int status = mvcResult.getResponse().getStatus(); assertEquals(200, status); }
|
@RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) public @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto) { Long userId = null; if (serverContext.getRequestContext() != null) { userId = serverContext.getRequestContext().getUserId(); } activityLogger.log(ActivityType.DELETE_ISL, linkParametersDto.toString()); return serviceSwitch.deleteLink(linkParametersDto, userId); }
|
SwitchController { @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) public @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto) { Long userId = null; if (serverContext.getRequestContext() != null) { userId = serverContext.getRequestContext().getUserId(); } activityLogger.log(ActivityType.DELETE_ISL, linkParametersDto.toString()); return serviceSwitch.deleteLink(linkParametersDto, userId); } }
|
SwitchController { @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) public @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto) { Long userId = null; if (serverContext.getRequestContext() != null) { userId = serverContext.getRequestContext().getUserId(); } activityLogger.log(ActivityType.DELETE_ISL, linkParametersDto.toString()); return serviceSwitch.deleteLink(linkParametersDto, userId); } }
|
SwitchController { @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) public @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto) { Long userId = null; if (serverContext.getRequestContext() != null) { userId = serverContext.getRequestContext().getUserId(); } activityLogger.log(ActivityType.DELETE_ISL, linkParametersDto.toString()); return serviceSwitch.deleteLink(linkParametersDto, userId); } @RequestMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<SwitchInfo> getSwitchesDetail(
@RequestParam(value = "storeConfigurationStatus", required = false)
final boolean storeConfigurationStatus,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody SwitchInfo getSwitchDetail(@PathVariable final String switchId,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/name/{switchId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_UPDATE_NAME}) @ResponseBody SwitchInfo saveOrUpdateSwitchName(@PathVariable final String switchId,
@RequestBody final String switchName); @RequestMapping(value = "/links", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody List<IslLinkInfo> getLinksDetail(@RequestParam(value = "src_switch",
required = false) final String srcSwitch, @RequestParam(value = "src_port",
required = false) final String srcPort, @RequestParam(value = "dst_switch",
required = false) final String dstSwitch, @RequestParam(value = "dst_port",
required = false) final String dstPort); @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto); @RequestMapping(path = "/links/under-maintenance", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_MAINTENANCE}) @ResponseBody List<IslLinkInfo> updateLinkUnderMaintenance(
@RequestBody final LinkUnderMaintenanceDto linkUnderMaintenanceDto); @RequestMapping(path = "/link/props", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody LinkProps getLinkProps(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort); @RequestMapping(path = "/link/bandwidth", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BANDWIDTH}) @ResponseBody LinkMaxBandwidth updateMaxBandwidth(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort,
@RequestBody LinkMaxBandwidth linkMaxBandwidth); @RequestMapping(path = "/link/enable-bfd", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BFD_FLAG}) @ResponseBody List<IslLinkInfo> updateEnableBfdFlag(@RequestBody LinkParametersDto linkParametersDto); @RequestMapping(path = "/link/props", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody String updateLinkProps(@RequestBody final List<LinkProps> keys); @RequestMapping(path = "/{switchId}/rules", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PERMISSION_RULES}) @ResponseBody String getSwitchRules(@PathVariable final String switchId); @RequestMapping(path = "/{switchId}/{port}/config", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PORT_CONFIG}) @ResponseBody ConfiguredPort configureSwitchPort(
@RequestBody final PortConfiguration configuration,
@PathVariable final String switchId, @PathVariable final String port); @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId,
@RequestParam(value = "port", required = false) final String port,
@RequestParam(value = "inventory", required = false) final boolean inventory); @RequestMapping(value = "/links/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<FlowInfo> getIslFlows(@RequestParam(name = "src_switch",
required = true) final String srcSwitch, @RequestParam(name = "src_port",
required = true) final String srcPort, @RequestParam(name = "dst_switch",
required = true) final String dstSwitch, @RequestParam(name = "dst_port",
required = true) final String dstPort); @RequestMapping(value = "/meters/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_METERS}) @ResponseBody SwitchMeter getSwitchMeters(@PathVariable final String switchId); @RequestMapping(value = "/under-maintenance/{switchId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_MAINTENANCE}) @ResponseBody SwitchInfo updateSwitchMaintenanceStatus(
@PathVariable("switchId") final String switchId,
@RequestBody final SwitchInfo switchInfo); @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId,
@RequestParam(name = "force", required = false) boolean force); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port, @RequestBody SwitchProperty switchProperty); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port); }
|
SwitchController { @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) public @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto) { Long userId = null; if (serverContext.getRequestContext() != null) { userId = serverContext.getRequestContext().getUserId(); } activityLogger.log(ActivityType.DELETE_ISL, linkParametersDto.toString()); return serviceSwitch.deleteLink(linkParametersDto, userId); } @RequestMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<SwitchInfo> getSwitchesDetail(
@RequestParam(value = "storeConfigurationStatus", required = false)
final boolean storeConfigurationStatus,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody SwitchInfo getSwitchDetail(@PathVariable final String switchId,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/name/{switchId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_UPDATE_NAME}) @ResponseBody SwitchInfo saveOrUpdateSwitchName(@PathVariable final String switchId,
@RequestBody final String switchName); @RequestMapping(value = "/links", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody List<IslLinkInfo> getLinksDetail(@RequestParam(value = "src_switch",
required = false) final String srcSwitch, @RequestParam(value = "src_port",
required = false) final String srcPort, @RequestParam(value = "dst_switch",
required = false) final String dstSwitch, @RequestParam(value = "dst_port",
required = false) final String dstPort); @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto); @RequestMapping(path = "/links/under-maintenance", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_MAINTENANCE}) @ResponseBody List<IslLinkInfo> updateLinkUnderMaintenance(
@RequestBody final LinkUnderMaintenanceDto linkUnderMaintenanceDto); @RequestMapping(path = "/link/props", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody LinkProps getLinkProps(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort); @RequestMapping(path = "/link/bandwidth", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BANDWIDTH}) @ResponseBody LinkMaxBandwidth updateMaxBandwidth(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort,
@RequestBody LinkMaxBandwidth linkMaxBandwidth); @RequestMapping(path = "/link/enable-bfd", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BFD_FLAG}) @ResponseBody List<IslLinkInfo> updateEnableBfdFlag(@RequestBody LinkParametersDto linkParametersDto); @RequestMapping(path = "/link/props", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody String updateLinkProps(@RequestBody final List<LinkProps> keys); @RequestMapping(path = "/{switchId}/rules", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PERMISSION_RULES}) @ResponseBody String getSwitchRules(@PathVariable final String switchId); @RequestMapping(path = "/{switchId}/{port}/config", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PORT_CONFIG}) @ResponseBody ConfiguredPort configureSwitchPort(
@RequestBody final PortConfiguration configuration,
@PathVariable final String switchId, @PathVariable final String port); @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId,
@RequestParam(value = "port", required = false) final String port,
@RequestParam(value = "inventory", required = false) final boolean inventory); @RequestMapping(value = "/links/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<FlowInfo> getIslFlows(@RequestParam(name = "src_switch",
required = true) final String srcSwitch, @RequestParam(name = "src_port",
required = true) final String srcPort, @RequestParam(name = "dst_switch",
required = true) final String dstSwitch, @RequestParam(name = "dst_port",
required = true) final String dstPort); @RequestMapping(value = "/meters/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_METERS}) @ResponseBody SwitchMeter getSwitchMeters(@PathVariable final String switchId); @RequestMapping(value = "/under-maintenance/{switchId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_MAINTENANCE}) @ResponseBody SwitchInfo updateSwitchMaintenanceStatus(
@PathVariable("switchId") final String switchId,
@RequestBody final SwitchInfo switchInfo); @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId,
@RequestParam(name = "force", required = false) boolean force); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port, @RequestBody SwitchProperty switchProperty); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port); }
|
@Test public void testUpdateSwitchPortProperty() throws Exception { try { SwitchProperty switchProperty = new SwitchProperty(); switchProperty.setDiscoveryEnabled(true); String inputJson = mapToJson(switchProperty); MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders .put("/api/switch/{switchId}/ports/{port}/properties", TestSwitchMock.SWITCH_ID, TestSwitchMock.PORT) .content(inputJson) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andReturn(); int status = mvcResult.getResponse().getStatus(); assertEquals(200, status); } catch (Exception e) { System.out.println("Exception is: " + e); } }
|
@RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) public @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId, @PathVariable final String port, @RequestBody SwitchProperty switchProperty) { activityLogger.log(ActivityType.UPDATE_SW_PORT_PROPERTIES, switchId); return serviceSwitch.updateSwitchPortProperty(switchId, port, switchProperty); }
|
SwitchController { @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) public @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId, @PathVariable final String port, @RequestBody SwitchProperty switchProperty) { activityLogger.log(ActivityType.UPDATE_SW_PORT_PROPERTIES, switchId); return serviceSwitch.updateSwitchPortProperty(switchId, port, switchProperty); } }
|
SwitchController { @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) public @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId, @PathVariable final String port, @RequestBody SwitchProperty switchProperty) { activityLogger.log(ActivityType.UPDATE_SW_PORT_PROPERTIES, switchId); return serviceSwitch.updateSwitchPortProperty(switchId, port, switchProperty); } }
|
SwitchController { @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) public @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId, @PathVariable final String port, @RequestBody SwitchProperty switchProperty) { activityLogger.log(ActivityType.UPDATE_SW_PORT_PROPERTIES, switchId); return serviceSwitch.updateSwitchPortProperty(switchId, port, switchProperty); } @RequestMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<SwitchInfo> getSwitchesDetail(
@RequestParam(value = "storeConfigurationStatus", required = false)
final boolean storeConfigurationStatus,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody SwitchInfo getSwitchDetail(@PathVariable final String switchId,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/name/{switchId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_UPDATE_NAME}) @ResponseBody SwitchInfo saveOrUpdateSwitchName(@PathVariable final String switchId,
@RequestBody final String switchName); @RequestMapping(value = "/links", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody List<IslLinkInfo> getLinksDetail(@RequestParam(value = "src_switch",
required = false) final String srcSwitch, @RequestParam(value = "src_port",
required = false) final String srcPort, @RequestParam(value = "dst_switch",
required = false) final String dstSwitch, @RequestParam(value = "dst_port",
required = false) final String dstPort); @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto); @RequestMapping(path = "/links/under-maintenance", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_MAINTENANCE}) @ResponseBody List<IslLinkInfo> updateLinkUnderMaintenance(
@RequestBody final LinkUnderMaintenanceDto linkUnderMaintenanceDto); @RequestMapping(path = "/link/props", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody LinkProps getLinkProps(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort); @RequestMapping(path = "/link/bandwidth", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BANDWIDTH}) @ResponseBody LinkMaxBandwidth updateMaxBandwidth(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort,
@RequestBody LinkMaxBandwidth linkMaxBandwidth); @RequestMapping(path = "/link/enable-bfd", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BFD_FLAG}) @ResponseBody List<IslLinkInfo> updateEnableBfdFlag(@RequestBody LinkParametersDto linkParametersDto); @RequestMapping(path = "/link/props", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody String updateLinkProps(@RequestBody final List<LinkProps> keys); @RequestMapping(path = "/{switchId}/rules", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PERMISSION_RULES}) @ResponseBody String getSwitchRules(@PathVariable final String switchId); @RequestMapping(path = "/{switchId}/{port}/config", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PORT_CONFIG}) @ResponseBody ConfiguredPort configureSwitchPort(
@RequestBody final PortConfiguration configuration,
@PathVariable final String switchId, @PathVariable final String port); @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId,
@RequestParam(value = "port", required = false) final String port,
@RequestParam(value = "inventory", required = false) final boolean inventory); @RequestMapping(value = "/links/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<FlowInfo> getIslFlows(@RequestParam(name = "src_switch",
required = true) final String srcSwitch, @RequestParam(name = "src_port",
required = true) final String srcPort, @RequestParam(name = "dst_switch",
required = true) final String dstSwitch, @RequestParam(name = "dst_port",
required = true) final String dstPort); @RequestMapping(value = "/meters/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_METERS}) @ResponseBody SwitchMeter getSwitchMeters(@PathVariable final String switchId); @RequestMapping(value = "/under-maintenance/{switchId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_MAINTENANCE}) @ResponseBody SwitchInfo updateSwitchMaintenanceStatus(
@PathVariable("switchId") final String switchId,
@RequestBody final SwitchInfo switchInfo); @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId,
@RequestParam(name = "force", required = false) boolean force); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port, @RequestBody SwitchProperty switchProperty); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port); }
|
SwitchController { @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) public @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId, @PathVariable final String port, @RequestBody SwitchProperty switchProperty) { activityLogger.log(ActivityType.UPDATE_SW_PORT_PROPERTIES, switchId); return serviceSwitch.updateSwitchPortProperty(switchId, port, switchProperty); } @RequestMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<SwitchInfo> getSwitchesDetail(
@RequestParam(value = "storeConfigurationStatus", required = false)
final boolean storeConfigurationStatus,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody SwitchInfo getSwitchDetail(@PathVariable final String switchId,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/name/{switchId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_UPDATE_NAME}) @ResponseBody SwitchInfo saveOrUpdateSwitchName(@PathVariable final String switchId,
@RequestBody final String switchName); @RequestMapping(value = "/links", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody List<IslLinkInfo> getLinksDetail(@RequestParam(value = "src_switch",
required = false) final String srcSwitch, @RequestParam(value = "src_port",
required = false) final String srcPort, @RequestParam(value = "dst_switch",
required = false) final String dstSwitch, @RequestParam(value = "dst_port",
required = false) final String dstPort); @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto); @RequestMapping(path = "/links/under-maintenance", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_MAINTENANCE}) @ResponseBody List<IslLinkInfo> updateLinkUnderMaintenance(
@RequestBody final LinkUnderMaintenanceDto linkUnderMaintenanceDto); @RequestMapping(path = "/link/props", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody LinkProps getLinkProps(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort); @RequestMapping(path = "/link/bandwidth", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BANDWIDTH}) @ResponseBody LinkMaxBandwidth updateMaxBandwidth(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort,
@RequestBody LinkMaxBandwidth linkMaxBandwidth); @RequestMapping(path = "/link/enable-bfd", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BFD_FLAG}) @ResponseBody List<IslLinkInfo> updateEnableBfdFlag(@RequestBody LinkParametersDto linkParametersDto); @RequestMapping(path = "/link/props", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody String updateLinkProps(@RequestBody final List<LinkProps> keys); @RequestMapping(path = "/{switchId}/rules", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PERMISSION_RULES}) @ResponseBody String getSwitchRules(@PathVariable final String switchId); @RequestMapping(path = "/{switchId}/{port}/config", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PORT_CONFIG}) @ResponseBody ConfiguredPort configureSwitchPort(
@RequestBody final PortConfiguration configuration,
@PathVariable final String switchId, @PathVariable final String port); @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId,
@RequestParam(value = "port", required = false) final String port,
@RequestParam(value = "inventory", required = false) final boolean inventory); @RequestMapping(value = "/links/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<FlowInfo> getIslFlows(@RequestParam(name = "src_switch",
required = true) final String srcSwitch, @RequestParam(name = "src_port",
required = true) final String srcPort, @RequestParam(name = "dst_switch",
required = true) final String dstSwitch, @RequestParam(name = "dst_port",
required = true) final String dstPort); @RequestMapping(value = "/meters/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_METERS}) @ResponseBody SwitchMeter getSwitchMeters(@PathVariable final String switchId); @RequestMapping(value = "/under-maintenance/{switchId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_MAINTENANCE}) @ResponseBody SwitchInfo updateSwitchMaintenanceStatus(
@PathVariable("switchId") final String switchId,
@RequestBody final SwitchInfo switchInfo); @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId,
@RequestParam(name = "force", required = false) boolean force); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port, @RequestBody SwitchProperty switchProperty); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port); }
|
@Test public void testGetSwitchPortProperties() { SwitchProperty switchProperty = new SwitchProperty(); try { when(serviceSwitch.getSwitchPortProperty(TestSwitchMock.SWITCH_ID, TestSwitchMock.PORT)) .thenReturn(switchProperty); mockMvc.perform(get("/api/switch/{switchId}/ports/{port}/properties", TestSwitchMock.SWITCH_ID, TestSwitchMock.SWITCH_PORT).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); assertTrue(true); } catch (Exception e) { assertTrue(false); } }
|
@RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId, @PathVariable final String port) { return serviceSwitch.getSwitchPortProperty(switchId, port); }
|
SwitchController { @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId, @PathVariable final String port) { return serviceSwitch.getSwitchPortProperty(switchId, port); } }
|
SwitchController { @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId, @PathVariable final String port) { return serviceSwitch.getSwitchPortProperty(switchId, port); } }
|
SwitchController { @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId, @PathVariable final String port) { return serviceSwitch.getSwitchPortProperty(switchId, port); } @RequestMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<SwitchInfo> getSwitchesDetail(
@RequestParam(value = "storeConfigurationStatus", required = false)
final boolean storeConfigurationStatus,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody SwitchInfo getSwitchDetail(@PathVariable final String switchId,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/name/{switchId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_UPDATE_NAME}) @ResponseBody SwitchInfo saveOrUpdateSwitchName(@PathVariable final String switchId,
@RequestBody final String switchName); @RequestMapping(value = "/links", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody List<IslLinkInfo> getLinksDetail(@RequestParam(value = "src_switch",
required = false) final String srcSwitch, @RequestParam(value = "src_port",
required = false) final String srcPort, @RequestParam(value = "dst_switch",
required = false) final String dstSwitch, @RequestParam(value = "dst_port",
required = false) final String dstPort); @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto); @RequestMapping(path = "/links/under-maintenance", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_MAINTENANCE}) @ResponseBody List<IslLinkInfo> updateLinkUnderMaintenance(
@RequestBody final LinkUnderMaintenanceDto linkUnderMaintenanceDto); @RequestMapping(path = "/link/props", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody LinkProps getLinkProps(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort); @RequestMapping(path = "/link/bandwidth", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BANDWIDTH}) @ResponseBody LinkMaxBandwidth updateMaxBandwidth(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort,
@RequestBody LinkMaxBandwidth linkMaxBandwidth); @RequestMapping(path = "/link/enable-bfd", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BFD_FLAG}) @ResponseBody List<IslLinkInfo> updateEnableBfdFlag(@RequestBody LinkParametersDto linkParametersDto); @RequestMapping(path = "/link/props", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody String updateLinkProps(@RequestBody final List<LinkProps> keys); @RequestMapping(path = "/{switchId}/rules", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PERMISSION_RULES}) @ResponseBody String getSwitchRules(@PathVariable final String switchId); @RequestMapping(path = "/{switchId}/{port}/config", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PORT_CONFIG}) @ResponseBody ConfiguredPort configureSwitchPort(
@RequestBody final PortConfiguration configuration,
@PathVariable final String switchId, @PathVariable final String port); @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId,
@RequestParam(value = "port", required = false) final String port,
@RequestParam(value = "inventory", required = false) final boolean inventory); @RequestMapping(value = "/links/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<FlowInfo> getIslFlows(@RequestParam(name = "src_switch",
required = true) final String srcSwitch, @RequestParam(name = "src_port",
required = true) final String srcPort, @RequestParam(name = "dst_switch",
required = true) final String dstSwitch, @RequestParam(name = "dst_port",
required = true) final String dstPort); @RequestMapping(value = "/meters/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_METERS}) @ResponseBody SwitchMeter getSwitchMeters(@PathVariable final String switchId); @RequestMapping(value = "/under-maintenance/{switchId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_MAINTENANCE}) @ResponseBody SwitchInfo updateSwitchMaintenanceStatus(
@PathVariable("switchId") final String switchId,
@RequestBody final SwitchInfo switchInfo); @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId,
@RequestParam(name = "force", required = false) boolean force); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port, @RequestBody SwitchProperty switchProperty); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port); }
|
SwitchController { @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId, @PathVariable final String port) { return serviceSwitch.getSwitchPortProperty(switchId, port); } @RequestMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<SwitchInfo> getSwitchesDetail(
@RequestParam(value = "storeConfigurationStatus", required = false)
final boolean storeConfigurationStatus,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody SwitchInfo getSwitchDetail(@PathVariable final String switchId,
@RequestParam(value = "controller", required = false)
final boolean controller); @RequestMapping(value = "/name/{switchId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_UPDATE_NAME}) @ResponseBody SwitchInfo saveOrUpdateSwitchName(@PathVariable final String switchId,
@RequestBody final String switchName); @RequestMapping(value = "/links", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody List<IslLinkInfo> getLinksDetail(@RequestParam(value = "src_switch",
required = false) final String srcSwitch, @RequestParam(value = "src_port",
required = false) final String srcPort, @RequestParam(value = "dst_switch",
required = false) final String dstSwitch, @RequestParam(value = "dst_port",
required = false) final String dstPort); @RequestMapping(value = "/links", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.ISL_DELETE_LINK }) @ResponseBody List<IslLinkInfo> deleteIsl(@RequestBody final LinkParametersDto linkParametersDto); @RequestMapping(path = "/links/under-maintenance", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_MAINTENANCE}) @ResponseBody List<IslLinkInfo> updateLinkUnderMaintenance(
@RequestBody final LinkUnderMaintenanceDto linkUnderMaintenanceDto); @RequestMapping(path = "/link/props", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody LinkProps getLinkProps(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort); @RequestMapping(path = "/link/bandwidth", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BANDWIDTH}) @ResponseBody LinkMaxBandwidth updateMaxBandwidth(
@RequestParam(value = "src_switch", required = true) final String srcSwitch,
@RequestParam(value = "src_port", required = true) final String srcPort, @RequestParam(
value = "dst_switch", required = true) final String dstSwitch, @RequestParam(
value = "dst_port", required = true) final String dstPort,
@RequestBody LinkMaxBandwidth linkMaxBandwidth); @RequestMapping(path = "/link/enable-bfd", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.ISL_UPDATE_BFD_FLAG}) @ResponseBody List<IslLinkInfo> updateEnableBfdFlag(@RequestBody LinkParametersDto linkParametersDto); @RequestMapping(path = "/link/props", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody String updateLinkProps(@RequestBody final List<LinkProps> keys); @RequestMapping(path = "/{switchId}/rules", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PERMISSION_RULES}) @ResponseBody String getSwitchRules(@PathVariable final String switchId); @RequestMapping(path = "/{switchId}/{port}/config", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_PORT_CONFIG}) @ResponseBody ConfiguredPort configureSwitchPort(
@RequestBody final PortConfiguration configuration,
@PathVariable final String switchId, @PathVariable final String port); @RequestMapping(path = "/{switchId}/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody ResponseEntity<List<?>> getPortFlows(@PathVariable final String switchId,
@RequestParam(value = "port", required = false) final String port,
@RequestParam(value = "inventory", required = false) final boolean inventory); @RequestMapping(value = "/links/flows", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<FlowInfo> getIslFlows(@RequestParam(name = "src_switch",
required = true) final String srcSwitch, @RequestParam(name = "src_port",
required = true) final String srcPort, @RequestParam(name = "dst_switch",
required = true) final String dstSwitch, @RequestParam(name = "dst_port",
required = true) final String dstPort); @RequestMapping(value = "/meters/{switchId}") @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_METERS}) @ResponseBody SwitchMeter getSwitchMeters(@PathVariable final String switchId); @RequestMapping(value = "/under-maintenance/{switchId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @Permissions(values = {IConstants.Permission.SW_SWITCH_MAINTENANCE}) @ResponseBody SwitchInfo updateSwitchMaintenanceStatus(
@PathVariable("switchId") final String switchId,
@RequestBody final SwitchInfo switchInfo); @RequestMapping(value = "/{switchId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_SWITCH_DELETE }) @ResponseBody SwitchInfo deleteSwitch(@PathVariable final String switchId,
@RequestParam(name = "force", required = false) boolean force); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.SW_UPDATE_PORT_PROPERTIES }) @ResponseBody SwitchProperty updateSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port, @RequestBody SwitchProperty switchProperty); @RequestMapping(value = "/{switchId}/ports/{port}/properties", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody SwitchProperty getSwitchPortProperty(@PathVariable final String switchId,
@PathVariable final String port); }
|
@Test public void testGetFlowStats() throws Exception { try { mockMvc.perform( get("/api/stats/flowid/{flowId}/{startDate}/{endDate}/{downsample}/{metric}", TestMockStats.FLOW_ID, TestMockStats.START_DATE, TestMockStats.END_DATE, TestMockStats.DOWNSAMPLE, TestMockStats.METRIC_BITS, TestMockStats.DIRECTION_FORWARD) .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()); assertTrue(true); } catch (Exception ex) { assertTrue(false); } }
|
@RequestMapping(value = "flowid/{flowid}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody public String getFlowStats(@PathVariable String flowid, @PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric) throws Exception { LOGGER.info("Get stat for flow"); return statsService.getFlowStats(startDate, endDate, downsample, flowid, metric); }
|
StatsController { @RequestMapping(value = "flowid/{flowid}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody public String getFlowStats(@PathVariable String flowid, @PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric) throws Exception { LOGGER.info("Get stat for flow"); return statsService.getFlowStats(startDate, endDate, downsample, flowid, metric); } }
|
StatsController { @RequestMapping(value = "flowid/{flowid}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody public String getFlowStats(@PathVariable String flowid, @PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric) throws Exception { LOGGER.info("Get stat for flow"); return statsService.getFlowStats(startDate, endDate, downsample, flowid, metric); } }
|
StatsController { @RequestMapping(value = "flowid/{flowid}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody public String getFlowStats(@PathVariable String flowid, @PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric) throws Exception { LOGGER.info("Get stat for flow"); return statsService.getFlowStats(startDate, endDate, downsample, flowid, metric); } @RequestMapping(value = "/metrics") @ResponseStatus(HttpStatus.OK) @ResponseBody List<String> getMetricDetail(); @RequestMapping(value = "isl/{srcSwitch}/{srcPort}/{dstSwitch}/{dstPort}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody String getIslStats(@PathVariable String srcSwitch, @PathVariable String srcPort,
@PathVariable String dstSwitch, @PathVariable String dstPort, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric); @RequestMapping(value = "switchid/{switchid}/port/{port}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody String getPortStats(@PathVariable String switchid, @PathVariable String port,
@PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample,
@PathVariable String metric); @RequestMapping(value = "flowid/{flowid}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody String getFlowStats(@PathVariable String flowid, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric); @RequestMapping(value = "isl/losspackets/{srcSwitch}/{srcPort}/{dstSwitch}/{dstPort}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody String getIslLossPacketStats(@PathVariable String srcSwitch, @PathVariable String srcPort,
@PathVariable String dstSwitch, @PathVariable String dstPort, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric); @RequestMapping(value = "flow/losspackets/{flowid}/{startDate}/{endDate}/{downsample}/{direction}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody String getFlowLossPacketStats(@PathVariable String flowid, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample, @PathVariable String direction); @RequestMapping(value = "flowpath", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody String getFlowPathStat(@RequestBody FlowPathStats flowPathStats); @RequestMapping(value = "switchports/{switchid}/{startDate}/{endDate}/{downsample}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<PortInfo> getSwitchPortsStats(@PathVariable String switchid,
@PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample); @RequestMapping(value = "meter/{flowid}/{startDate}/{endDate}/{downsample}/{metric}/{direction}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody String getMeterStats(@PathVariable String flowid, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample,
@PathVariable String metric, @PathVariable String direction); }
|
StatsController { @RequestMapping(value = "flowid/{flowid}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody public String getFlowStats(@PathVariable String flowid, @PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric) throws Exception { LOGGER.info("Get stat for flow"); return statsService.getFlowStats(startDate, endDate, downsample, flowid, metric); } @RequestMapping(value = "/metrics") @ResponseStatus(HttpStatus.OK) @ResponseBody List<String> getMetricDetail(); @RequestMapping(value = "isl/{srcSwitch}/{srcPort}/{dstSwitch}/{dstPort}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody String getIslStats(@PathVariable String srcSwitch, @PathVariable String srcPort,
@PathVariable String dstSwitch, @PathVariable String dstPort, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric); @RequestMapping(value = "switchid/{switchid}/port/{port}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody String getPortStats(@PathVariable String switchid, @PathVariable String port,
@PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample,
@PathVariable String metric); @RequestMapping(value = "flowid/{flowid}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody String getFlowStats(@PathVariable String flowid, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric); @RequestMapping(value = "isl/losspackets/{srcSwitch}/{srcPort}/{dstSwitch}/{dstPort}/{startDate}/{endDate}/{downsample}/{metric}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_ISL }) @ResponseBody String getIslLossPacketStats(@PathVariable String srcSwitch, @PathVariable String srcPort,
@PathVariable String dstSwitch, @PathVariable String dstPort, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric); @RequestMapping(value = "flow/losspackets/{flowid}/{startDate}/{endDate}/{downsample}/{direction}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody String getFlowLossPacketStats(@PathVariable String flowid, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample, @PathVariable String direction); @RequestMapping(value = "flowpath", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody String getFlowPathStat(@RequestBody FlowPathStats flowPathStats); @RequestMapping(value = "switchports/{switchid}/{startDate}/{endDate}/{downsample}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_SWITCHES }) @ResponseBody List<PortInfo> getSwitchPortsStats(@PathVariable String switchid,
@PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample); @RequestMapping(value = "meter/{flowid}/{startDate}/{endDate}/{downsample}/{metric}/{direction}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Permissions(values = { IConstants.Permission.MENU_FLOWS }) @ResponseBody String getMeterStats(@PathVariable String flowid, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample,
@PathVariable String metric, @PathVariable String direction); }
|
@Test public void errorDetection() throws Exception { Future promise = mock(Future.class); final ExecutionException error = new ExecutionException("Emulate kafka send error", new IOException()); expect(promise.get()).andThrow(error).anyTimes(); replay(promise); expect(kafkaProducer.send(anyObject(), anyObject(Callback.class))).andReturn(promise); replay(kafkaProducer); SendStatus status = subject.sendMessage(TOPIC, makePayload()); verify(kafkaProducer); Boolean isThrown; try { status.waitTillComplete(); isThrown = false; } catch (ExecutionException e) { isThrown = true; } Assert.assertTrue(String.format( "Exception was not thrown by %s object", status.getClass().getCanonicalName()), isThrown); }
|
public SendStatus sendMessage(String topic, Message message) { SendStatus sendStatus = produce(encode(topic, message), null); return sendStatus; }
|
KafkaProducerService implements IKafkaProducerService { public SendStatus sendMessage(String topic, Message message) { SendStatus sendStatus = produce(encode(topic, message), null); return sendStatus; } }
|
KafkaProducerService implements IKafkaProducerService { public SendStatus sendMessage(String topic, Message message) { SendStatus sendStatus = produce(encode(topic, message), null); return sendStatus; } }
|
KafkaProducerService implements IKafkaProducerService { public SendStatus sendMessage(String topic, Message message) { SendStatus sendStatus = produce(encode(topic, message), null); return sendStatus; } @Override void setup(FloodlightModuleContext moduleContext); void sendMessageAndTrack(String topic, Message message); void sendMessageAndTrack(String topic, String key, Message message); @Override void sendMessageAndTrack(String topic, String key, AbstractMessage message); SendStatus sendMessage(String topic, Message message); int getFailedSendMessageCounter(); }
|
KafkaProducerService implements IKafkaProducerService { public SendStatus sendMessage(String topic, Message message) { SendStatus sendStatus = produce(encode(topic, message), null); return sendStatus; } @Override void setup(FloodlightModuleContext moduleContext); void sendMessageAndTrack(String topic, Message message); void sendMessageAndTrack(String topic, String key, Message message); @Override void sendMessageAndTrack(String topic, String key, AbstractMessage message); SendStatus sendMessage(String topic, Message message); int getFailedSendMessageCounter(); }
|
@Test public void addWatch() { WatcherService w = new WatcherService(carrier, 10); w.addWatch(new SwitchId(1), 1, 1); w.addWatch(new SwitchId(1), 2, 1); w.addWatch(new SwitchId(2), 1, 2); w.addWatch(new SwitchId(2), 1, 2); w.addWatch(new SwitchId(2), 2, 3); assertThat(w.getConfirmations().size(), is(0)); assertThat(w.getTimeouts().size(), is(3)); verify(carrier, times(5)).sendDiscovery(any(SwitchId.class), anyInt(), anyLong(), anyLong()); }
|
public void addWatch(SwitchId switchId, int portNo, long currentTime) { Packet packet = Packet.of(switchId, portNo, packetNo); timeouts.computeIfAbsent(currentTime + awaitTime, mappingFunction -> new HashSet<>()) .add(packet); carrier.sendDiscovery(switchId, portNo, packetNo, currentTime); packetNo += 1; }
|
WatcherService { public void addWatch(SwitchId switchId, int portNo, long currentTime) { Packet packet = Packet.of(switchId, portNo, packetNo); timeouts.computeIfAbsent(currentTime + awaitTime, mappingFunction -> new HashSet<>()) .add(packet); carrier.sendDiscovery(switchId, portNo, packetNo, currentTime); packetNo += 1; } }
|
WatcherService { public void addWatch(SwitchId switchId, int portNo, long currentTime) { Packet packet = Packet.of(switchId, portNo, packetNo); timeouts.computeIfAbsent(currentTime + awaitTime, mappingFunction -> new HashSet<>()) .add(packet); carrier.sendDiscovery(switchId, portNo, packetNo, currentTime); packetNo += 1; } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); }
|
WatcherService { public void addWatch(SwitchId switchId, int portNo, long currentTime) { Packet packet = Packet.of(switchId, portNo, packetNo); timeouts.computeIfAbsent(currentTime + awaitTime, mappingFunction -> new HashSet<>()) .add(packet); carrier.sendDiscovery(switchId, portNo, packetNo, currentTime); packetNo += 1; } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); void addWatch(SwitchId switchId, int portNo, long currentTime); void removeWatch(SwitchId switchId, int portNo); void tick(long tickTime); void confirmation(SwitchId switchId, int portNo, long packetNo); void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime); Set<Packet> getConfirmations(); SortedMap<Long, Set<Packet>> getTimeouts(); }
|
WatcherService { public void addWatch(SwitchId switchId, int portNo, long currentTime) { Packet packet = Packet.of(switchId, portNo, packetNo); timeouts.computeIfAbsent(currentTime + awaitTime, mappingFunction -> new HashSet<>()) .add(packet); carrier.sendDiscovery(switchId, portNo, packetNo, currentTime); packetNo += 1; } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); void addWatch(SwitchId switchId, int portNo, long currentTime); void removeWatch(SwitchId switchId, int portNo); void tick(long tickTime); void confirmation(SwitchId switchId, int portNo, long packetNo); void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime); Set<Packet> getConfirmations(); SortedMap<Long, Set<Packet>> getTimeouts(); }
|
@Test public void removeWatch() { }
|
public void removeWatch(SwitchId switchId, int portNo) { }
|
WatcherService { public void removeWatch(SwitchId switchId, int portNo) { } }
|
WatcherService { public void removeWatch(SwitchId switchId, int portNo) { } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); }
|
WatcherService { public void removeWatch(SwitchId switchId, int portNo) { } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); void addWatch(SwitchId switchId, int portNo, long currentTime); void removeWatch(SwitchId switchId, int portNo); void tick(long tickTime); void confirmation(SwitchId switchId, int portNo, long packetNo); void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime); Set<Packet> getConfirmations(); SortedMap<Long, Set<Packet>> getTimeouts(); }
|
WatcherService { public void removeWatch(SwitchId switchId, int portNo) { } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); void addWatch(SwitchId switchId, int portNo, long currentTime); void removeWatch(SwitchId switchId, int portNo); void tick(long tickTime); void confirmation(SwitchId switchId, int portNo, long packetNo); void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime); Set<Packet> getConfirmations(); SortedMap<Long, Set<Packet>> getTimeouts(); }
|
@Test public void tick() { WatcherService w = new WatcherService(carrier, 10); w.addWatch(new SwitchId(1), 1, 1); w.addWatch(new SwitchId(1), 2, 1); w.addWatch(new SwitchId(2), 1, 2); w.addWatch(new SwitchId(2), 1, 2); w.addWatch(new SwitchId(2), 2, 3); assertThat(w.getConfirmations().size(), is(0)); assertThat(w.getTimeouts().size(), is(3)); verify(carrier, times(5)).sendDiscovery(any(SwitchId.class), anyInt(), anyLong(), anyLong()); w.confirmation(new SwitchId(1), 1, 0); w.confirmation(new SwitchId(2), 1, 2); assertThat(w.getConfirmations().size(), is(2)); w.tick(100); assertThat(w.getConfirmations().size(), is(0)); verify(carrier).failed(eq(new SwitchId(1)), eq(1), anyLong()); verify(carrier).failed(eq(new SwitchId(2)), eq(1), anyLong()); verify(carrier, times(2)).failed(any(SwitchId.class), anyInt(), anyLong()); assertThat(w.getTimeouts().size(), is(0)); }
|
public void tick(long tickTime) { SortedMap<Long, Set<Packet>> range = timeouts.subMap(0L, tickTime + 1); if (!range.isEmpty()) { for (Set<Packet> e : range.values()) { for (Packet ee : e) { if (confirmations.remove(ee)) { carrier.failed(ee.switchId, ee.port, tickTime); } } } range.clear(); } }
|
WatcherService { public void tick(long tickTime) { SortedMap<Long, Set<Packet>> range = timeouts.subMap(0L, tickTime + 1); if (!range.isEmpty()) { for (Set<Packet> e : range.values()) { for (Packet ee : e) { if (confirmations.remove(ee)) { carrier.failed(ee.switchId, ee.port, tickTime); } } } range.clear(); } } }
|
WatcherService { public void tick(long tickTime) { SortedMap<Long, Set<Packet>> range = timeouts.subMap(0L, tickTime + 1); if (!range.isEmpty()) { for (Set<Packet> e : range.values()) { for (Packet ee : e) { if (confirmations.remove(ee)) { carrier.failed(ee.switchId, ee.port, tickTime); } } } range.clear(); } } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); }
|
WatcherService { public void tick(long tickTime) { SortedMap<Long, Set<Packet>> range = timeouts.subMap(0L, tickTime + 1); if (!range.isEmpty()) { for (Set<Packet> e : range.values()) { for (Packet ee : e) { if (confirmations.remove(ee)) { carrier.failed(ee.switchId, ee.port, tickTime); } } } range.clear(); } } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); void addWatch(SwitchId switchId, int portNo, long currentTime); void removeWatch(SwitchId switchId, int portNo); void tick(long tickTime); void confirmation(SwitchId switchId, int portNo, long packetNo); void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime); Set<Packet> getConfirmations(); SortedMap<Long, Set<Packet>> getTimeouts(); }
|
WatcherService { public void tick(long tickTime) { SortedMap<Long, Set<Packet>> range = timeouts.subMap(0L, tickTime + 1); if (!range.isEmpty()) { for (Set<Packet> e : range.values()) { for (Packet ee : e) { if (confirmations.remove(ee)) { carrier.failed(ee.switchId, ee.port, tickTime); } } } range.clear(); } } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); void addWatch(SwitchId switchId, int portNo, long currentTime); void removeWatch(SwitchId switchId, int portNo); void tick(long tickTime); void confirmation(SwitchId switchId, int portNo, long packetNo); void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime); Set<Packet> getConfirmations(); SortedMap<Long, Set<Packet>> getTimeouts(); }
|
@Test public void discovery() { WatcherService w = new WatcherService(carrier, 10); w.addWatch(new SwitchId(1), 1, 1); w.addWatch(new SwitchId(1), 2, 1); w.addWatch(new SwitchId(2), 1, 2); w.addWatch(new SwitchId(2), 1, 2); w.addWatch(new SwitchId(2), 2, 3); assertThat(w.getConfirmations().size(), is(0)); assertThat(w.getTimeouts().size(), is(3)); verify(carrier, times(5)).sendDiscovery(any(SwitchId.class), anyInt(), anyLong(), anyLong()); w.confirmation(new SwitchId(1), 1, 0); w.confirmation(new SwitchId(2), 1, 2); assertThat(w.getConfirmations().size(), is(2)); w.discovery(new SwitchId(1), 1, new SwitchId(2), 1, 0, 4); w.discovery(new SwitchId(2), 1, new SwitchId(1), 1, 2, 4); w.tick(100); assertThat(w.getConfirmations().size(), is(0)); verify(carrier).discovered(eq(new SwitchId(1)), eq(1), eq(new SwitchId(2)), eq(1), anyLong()); verify(carrier).discovered(eq(new SwitchId(2)), eq(1), eq(new SwitchId(1)), eq(1), anyLong()); verify(carrier, times(2)).discovered(any(SwitchId.class), anyInt(), any(SwitchId.class), anyInt(), anyLong()); assertThat(w.getTimeouts().size(), is(0)); }
|
public void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime) { Packet packet = Packet.of(switchId, portNo, packetNo); confirmations.remove(packet); carrier.discovered(switchId, portNo, endSwitchId, endPortNo, currentTime); }
|
WatcherService { public void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime) { Packet packet = Packet.of(switchId, portNo, packetNo); confirmations.remove(packet); carrier.discovered(switchId, portNo, endSwitchId, endPortNo, currentTime); } }
|
WatcherService { public void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime) { Packet packet = Packet.of(switchId, portNo, packetNo); confirmations.remove(packet); carrier.discovered(switchId, portNo, endSwitchId, endPortNo, currentTime); } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); }
|
WatcherService { public void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime) { Packet packet = Packet.of(switchId, portNo, packetNo); confirmations.remove(packet); carrier.discovered(switchId, portNo, endSwitchId, endPortNo, currentTime); } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); void addWatch(SwitchId switchId, int portNo, long currentTime); void removeWatch(SwitchId switchId, int portNo); void tick(long tickTime); void confirmation(SwitchId switchId, int portNo, long packetNo); void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime); Set<Packet> getConfirmations(); SortedMap<Long, Set<Packet>> getTimeouts(); }
|
WatcherService { public void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime) { Packet packet = Packet.of(switchId, portNo, packetNo); confirmations.remove(packet); carrier.discovered(switchId, portNo, endSwitchId, endPortNo, currentTime); } WatcherService(IWatcherServiceCarrier carrier, long awaitTime); void addWatch(SwitchId switchId, int portNo, long currentTime); void removeWatch(SwitchId switchId, int portNo); void tick(long tickTime); void confirmation(SwitchId switchId, int portNo, long packetNo); void discovery(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long packetNo, long currentTime); Set<Packet> getConfirmations(); SortedMap<Long, Set<Packet>> getTimeouts(); }
|
@Test public void discovered() { DecisionMakerService w = new DecisionMakerService(carrier, 10, 5); w.discovered(new SwitchId(1), 10, new SwitchId(2), 20, 1L); w.discovered(new SwitchId(2), 20, new SwitchId(3), 30, 2L); verify(carrier).discovered(eq(new SwitchId(1)), eq(10), eq(new SwitchId(2)), eq(20), anyLong()); verify(carrier).discovered(eq(new SwitchId(2)), eq(20), eq(new SwitchId(3)), eq(30), anyLong()); }
|
void discovered(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long currentTime) { carrier.discovered(switchId, portNo, endSwitchId, endPortNo, currentTime); lastDiscovery.put(Endpoint.of(switchId, portNo), currentTime); }
|
DecisionMakerService { void discovered(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long currentTime) { carrier.discovered(switchId, portNo, endSwitchId, endPortNo, currentTime); lastDiscovery.put(Endpoint.of(switchId, portNo), currentTime); } }
|
DecisionMakerService { void discovered(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long currentTime) { carrier.discovered(switchId, portNo, endSwitchId, endPortNo, currentTime); lastDiscovery.put(Endpoint.of(switchId, portNo), currentTime); } DecisionMakerService(IDecisionMakerCarrier carrier, int failTimeout, int awaitTime); }
|
DecisionMakerService { void discovered(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long currentTime) { carrier.discovered(switchId, portNo, endSwitchId, endPortNo, currentTime); lastDiscovery.put(Endpoint.of(switchId, portNo), currentTime); } DecisionMakerService(IDecisionMakerCarrier carrier, int failTimeout, int awaitTime); HashMap<Endpoint, Long> getLastDiscovery(); }
|
DecisionMakerService { void discovered(SwitchId switchId, int portNo, SwitchId endSwitchId, int endPortNo, long currentTime) { carrier.discovered(switchId, portNo, endSwitchId, endPortNo, currentTime); lastDiscovery.put(Endpoint.of(switchId, portNo), currentTime); } DecisionMakerService(IDecisionMakerCarrier carrier, int failTimeout, int awaitTime); HashMap<Endpoint, Long> getLastDiscovery(); }
|
@Test public void failed() { DecisionMakerService w = new DecisionMakerService(carrier, 10, 5); w.failed(new SwitchId(1), 10, 0); w.failed(new SwitchId(1), 10, 1); w.failed(new SwitchId(1), 10, 11); w.failed(new SwitchId(1), 10, 12); verify(carrier, times(2)).failed(eq(new SwitchId(1)), eq(10), anyLong()); w.discovered(new SwitchId(1), 10, new SwitchId(2), 20, 20); verify(carrier).discovered(new SwitchId(1), 10, new SwitchId(2), 20, 20); reset(carrier); w.failed(new SwitchId(1), 10, 21); w.failed(new SwitchId(1), 10, 23); w.failed(new SwitchId(1), 10, 24); verify(carrier, never()).failed(any(SwitchId.class), anyInt(), anyInt()); w.failed(new SwitchId(1), 10, 31); verify(carrier).failed(new SwitchId(1), 10, 31); }
|
void failed(SwitchId switchId, int portNo, long currentTime) { Endpoint endpoint = Endpoint.of(switchId, portNo); if (!lastDiscovery.containsKey(endpoint)) { lastDiscovery.put(endpoint, currentTime - awaitTime); } long timeWindow = lastDiscovery.get(endpoint) + failTimeout; if (currentTime >= timeWindow) { carrier.failed(switchId, portNo, currentTime); } }
|
DecisionMakerService { void failed(SwitchId switchId, int portNo, long currentTime) { Endpoint endpoint = Endpoint.of(switchId, portNo); if (!lastDiscovery.containsKey(endpoint)) { lastDiscovery.put(endpoint, currentTime - awaitTime); } long timeWindow = lastDiscovery.get(endpoint) + failTimeout; if (currentTime >= timeWindow) { carrier.failed(switchId, portNo, currentTime); } } }
|
DecisionMakerService { void failed(SwitchId switchId, int portNo, long currentTime) { Endpoint endpoint = Endpoint.of(switchId, portNo); if (!lastDiscovery.containsKey(endpoint)) { lastDiscovery.put(endpoint, currentTime - awaitTime); } long timeWindow = lastDiscovery.get(endpoint) + failTimeout; if (currentTime >= timeWindow) { carrier.failed(switchId, portNo, currentTime); } } DecisionMakerService(IDecisionMakerCarrier carrier, int failTimeout, int awaitTime); }
|
DecisionMakerService { void failed(SwitchId switchId, int portNo, long currentTime) { Endpoint endpoint = Endpoint.of(switchId, portNo); if (!lastDiscovery.containsKey(endpoint)) { lastDiscovery.put(endpoint, currentTime - awaitTime); } long timeWindow = lastDiscovery.get(endpoint) + failTimeout; if (currentTime >= timeWindow) { carrier.failed(switchId, portNo, currentTime); } } DecisionMakerService(IDecisionMakerCarrier carrier, int failTimeout, int awaitTime); HashMap<Endpoint, Long> getLastDiscovery(); }
|
DecisionMakerService { void failed(SwitchId switchId, int portNo, long currentTime) { Endpoint endpoint = Endpoint.of(switchId, portNo); if (!lastDiscovery.containsKey(endpoint)) { lastDiscovery.put(endpoint, currentTime - awaitTime); } long timeWindow = lastDiscovery.get(endpoint) + failTimeout; if (currentTime >= timeWindow) { carrier.failed(switchId, portNo, currentTime); } } DecisionMakerService(IDecisionMakerCarrier carrier, int failTimeout, int awaitTime); HashMap<Endpoint, Long> getLastDiscovery(); }
|
@Test public void positive() throws Exception { IOFSwitch sw = createMock(IOFSwitch.class); setupSwitchMock(sw, dpId); swWriteAlwaysSuccess(sw); doneWithSetUp(sw); CompletableFuture<Optional<OFMessage>> future; OFPacketOut pktOut = makePacketOut(sw.getOFFactory(), 1); try (Session session = subject.open(context, sw)) { future = session.write(pktOut); } Assert.assertFalse(future.isDone()); List<OFMessage> swActualWrite = swWriteMessages.getValues(); Assert.assertEquals(2, swActualWrite.size()); Assert.assertEquals(pktOut, swActualWrite.get(0)); Assert.assertEquals(OFType.BARRIER_REQUEST, swActualWrite.get(1).getType()); completeSessions(sw); Assert.assertTrue(future.isDone()); Optional<OFMessage> response = future.get(); Assert.assertFalse(response.isPresent()); }
|
public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } Session open(IOFSwitch sw); Session open(MessageContext context, IOFSwitch sw); @Override void setup(FloodlightModuleContext moduleContext); @Override Command makeCommand(CommandContext context, OfInput input); }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } Session open(IOFSwitch sw); Session open(MessageContext context, IOFSwitch sw); @Override void setup(FloodlightModuleContext moduleContext); @Override Command makeCommand(CommandContext context, OfInput input); }
|
@Test public void switchWriteError() throws Throwable { IOFSwitch sw = createMock(IOFSwitch.class); setupSwitchMock(sw, dpId); swWriteSecondFail(sw); doneWithSetUp(sw); OFFactory ofFactory = sw.getOFFactory(); CompletableFuture<Optional<OFMessage>> future = null; try (Session session = subject.open(context, sw)) { session.write(makePacketOut(ofFactory, 1)); future = session.write(makePacketOut(ofFactory, 2)); } try { future.get(1, TimeUnit.SECONDS); Assert.fail(); } catch (ExecutionException e) { Assert.assertNotNull(e.getCause()); Assert.assertTrue(e.getCause() instanceof SwitchWriteException); } }
|
public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } Session open(IOFSwitch sw); Session open(MessageContext context, IOFSwitch sw); @Override void setup(FloodlightModuleContext moduleContext); @Override Command makeCommand(CommandContext context, OfInput input); }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } Session open(IOFSwitch sw); Session open(MessageContext context, IOFSwitch sw); @Override void setup(FloodlightModuleContext moduleContext); @Override Command makeCommand(CommandContext context, OfInput input); }
|
@Test public void sessionBarrierWriteError() throws Exception { IOFSwitch sw = createMock(IOFSwitch.class); setupSwitchMock(sw, dpId); swWriteSecondFail(sw); doneWithSetUp(sw); CompletableFuture<Optional<OFMessage>> future = null; try (Session session = subject.open(context, sw)) { future = session.write(makePacketOut(sw.getOFFactory(), 1)); } try { future.get(1, TimeUnit.SECONDS); Assert.fail(); } catch (ExecutionException e) { Assert.assertNotNull(e.getCause()); Assert.assertTrue(e.getCause() instanceof SessionCloseException); } }
|
public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } Session open(IOFSwitch sw); Session open(MessageContext context, IOFSwitch sw); @Override void setup(FloodlightModuleContext moduleContext); @Override Command makeCommand(CommandContext context, OfInput input); }
|
SessionService implements IService, IInputTranslator { public Session open(IOFSwitch sw) { return open(new MessageContext(), sw); } Session open(IOFSwitch sw); Session open(MessageContext context, IOFSwitch sw); @Override void setup(FloodlightModuleContext moduleContext); @Override Command makeCommand(CommandContext context, OfInput input); }
|
@Test public void deserializeLldpTest() { Ethernet ethernet = buildEthernet(srcAndDstMacAddresses, ethTypeToByteArray(EthType.LLDP), LldpPacketTest.packet); LldpPacketData data = service.deserializeLldp(ethernet, null, 0); assertNotNull(data); assertTrue(data.getVlans().isEmpty()); assertEquals(LldpPacketTest.buildLldpPacket(LldpPacketTest.packet), data.getLldpPacket()); }
|
@VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
@Test public void deserializeLldpWithVlanTest() { short vlan = 1234; Ethernet ethernet = buildEthernet(srcAndDstMacAddresses, ethTypeToByteArray(EthType.VLAN_FRAME), shortToByteArray(vlan), ethTypeToByteArray(EthType.LLDP), LldpPacketTest.packet); LldpPacketData data = service.deserializeLldp(ethernet, null, 0); assertNotNull(data); assertEquals(1, data.getVlans().size()); assertEquals(Integer.valueOf(vlan), data.getVlans().get(0)); assertEquals(LldpPacketTest.buildLldpPacket(LldpPacketTest.packet), data.getLldpPacket()); }
|
@VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
@Test public void deserializeLldpWithTwoVlanTest() { short innerVlan = 1234; short outerVlan = 2345; Ethernet ethernet = buildEthernet(srcAndDstMacAddresses, ethTypeToByteArray(EthType.VLAN_FRAME), shortToByteArray(outerVlan), ethTypeToByteArray(EthType.VLAN_FRAME), shortToByteArray(innerVlan), ethTypeToByteArray(EthType.LLDP), LldpPacketTest.packet); LldpPacketData data = service.deserializeLldp(ethernet, null, 0); assertNotNull(data); assertEquals(2, data.getVlans().size()); assertEquals(Integer.valueOf(outerVlan), data.getVlans().get(0)); assertEquals(Integer.valueOf(innerVlan), data.getVlans().get(1)); assertEquals(LldpPacketTest.buildLldpPacket(LldpPacketTest.packet), data.getLldpPacket()); }
|
@VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
@Test public void deserializeLldpWithQinQVlansTest() { short vlan1 = 1234; short vlan2 = 2345; short vlan3 = 4000; Ethernet ethernet = buildEthernet(srcAndDstMacAddresses, ethTypeToByteArray(EthType.Q_IN_Q), shortToByteArray(vlan1), ethTypeToByteArray(EthType.BRIDGING), shortToByteArray(vlan2), ethTypeToByteArray(EthType.VLAN_FRAME), shortToByteArray(vlan3), ethTypeToByteArray(EthType.LLDP), LldpPacketTest.packet); LldpPacketData data = service.deserializeLldp(ethernet, null, 0); assertNotNull(data); assertEquals(3, data.getVlans().size()); assertEquals(Integer.valueOf(vlan1), data.getVlans().get(0)); assertEquals(Integer.valueOf(vlan2), data.getVlans().get(1)); assertEquals(Integer.valueOf(vlan3), data.getVlans().get(2)); assertEquals(LldpPacketTest.buildLldpPacket(LldpPacketTest.packet), data.getLldpPacket()); }
|
@VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof LLDP) { LldpPacket lldpPacket = new LldpPacket((LLDP) payload); return new LldpPacketData(lldpPacket, vlans); } } catch (Exception exception) { logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
@Test public void deserializeArpTest() throws PacketParsingException { Ethernet ethernet = buildEthernet(srcAndDstMacAddresses, ethTypeToByteArray(EthType.ARP), arpPacket); ArpPacketData data = service.deserializeArp(ethernet, null, 0); assertNotNull(data); assertTrue(data.getVlans().isEmpty()); assertEquals(buildArpPacket(arpPacket), data.getArp()); }
|
@VisibleForTesting ArpPacketData deserializeArp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof ARP) { return new ArpPacketData((ARP) payload, vlans); } } catch (Exception exception) { logger.info("Could not deserialize ARP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid ARP packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting ArpPacketData deserializeArp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof ARP) { return new ArpPacketData((ARP) payload, vlans); } } catch (Exception exception) { logger.info("Could not deserialize ARP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid ARP packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting ArpPacketData deserializeArp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof ARP) { return new ArpPacketData((ARP) payload, vlans); } } catch (Exception exception) { logger.info("Could not deserialize ARP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid ARP packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting ArpPacketData deserializeArp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof ARP) { return new ArpPacketData((ARP) payload, vlans); } } catch (Exception exception) { logger.info("Could not deserialize ARP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid ARP packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting ArpPacketData deserializeArp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof ARP) { return new ArpPacketData((ARP) payload, vlans); } } catch (Exception exception) { logger.info("Could not deserialize ARP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid ARP packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
@Test(expected = IllegalSwitchPropertiesException.class) public void shouldValidateMultiTableFlagWhenUpdatingSwitchPropertiesWithArp() { Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build(); switchRepository.add(sw); createSwitchProperties(sw, Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN), true, false, true); SwitchPropertiesDto update = new SwitchPropertiesDto(); update.setSupportedTransitEncapsulation( Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN)); update.setMultiTable(false); update.setSwitchArp(true); switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update); }
|
public SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto) { if (isEmpty(switchPropertiesDto.getSupportedTransitEncapsulation())) { throw new IllegalSwitchPropertiesException("Supported transit encapsulations should not be null or empty"); } SwitchProperties update = SwitchPropertiesMapper.INSTANCE.map(switchPropertiesDto); UpdateSwitchPropertiesResult result = transactionManager.doInTransaction(() -> { SwitchProperties switchProperties = switchPropertiesRepository.findBySwitchId(switchId) .orElseThrow(() -> new SwitchPropertiesNotFoundException(switchId)); validateSwitchProperties(switchId, update); final boolean isSwitchSyncNeeded = isSwitchSyncNeeded(switchProperties, update); switchProperties.setMultiTable(update.isMultiTable()); switchProperties.setSwitchLldp(update.isSwitchLldp()); switchProperties.setSwitchArp(update.isSwitchArp()); switchProperties.setSupportedTransitEncapsulation(update.getSupportedTransitEncapsulation()); switchProperties.setServer42FlowRtt(update.isServer42FlowRtt()); switchProperties.setServer42Port(update.getServer42Port()); switchProperties.setServer42Vlan(update.getServer42Vlan()); switchProperties.setServer42MacAddress(update.getServer42MacAddress()); return new UpdateSwitchPropertiesResult( SwitchPropertiesMapper.INSTANCE.map(switchProperties), isSwitchSyncNeeded); }); if (result.isSwitchSyncRequired()) { carrier.requestSwitchSync(switchId); } if (switchPropertiesDto.isServer42FlowRtt()) { carrier.enableServer42FlowRttOnSwitch(switchId); } else { carrier.disableServer42FlowRttOnSwitch(switchId); } return result.switchPropertiesDto; }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto) { if (isEmpty(switchPropertiesDto.getSupportedTransitEncapsulation())) { throw new IllegalSwitchPropertiesException("Supported transit encapsulations should not be null or empty"); } SwitchProperties update = SwitchPropertiesMapper.INSTANCE.map(switchPropertiesDto); UpdateSwitchPropertiesResult result = transactionManager.doInTransaction(() -> { SwitchProperties switchProperties = switchPropertiesRepository.findBySwitchId(switchId) .orElseThrow(() -> new SwitchPropertiesNotFoundException(switchId)); validateSwitchProperties(switchId, update); final boolean isSwitchSyncNeeded = isSwitchSyncNeeded(switchProperties, update); switchProperties.setMultiTable(update.isMultiTable()); switchProperties.setSwitchLldp(update.isSwitchLldp()); switchProperties.setSwitchArp(update.isSwitchArp()); switchProperties.setSupportedTransitEncapsulation(update.getSupportedTransitEncapsulation()); switchProperties.setServer42FlowRtt(update.isServer42FlowRtt()); switchProperties.setServer42Port(update.getServer42Port()); switchProperties.setServer42Vlan(update.getServer42Vlan()); switchProperties.setServer42MacAddress(update.getServer42MacAddress()); return new UpdateSwitchPropertiesResult( SwitchPropertiesMapper.INSTANCE.map(switchProperties), isSwitchSyncNeeded); }); if (result.isSwitchSyncRequired()) { carrier.requestSwitchSync(switchId); } if (switchPropertiesDto.isServer42FlowRtt()) { carrier.enableServer42FlowRttOnSwitch(switchId); } else { carrier.disableServer42FlowRttOnSwitch(switchId); } return result.switchPropertiesDto; } }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto) { if (isEmpty(switchPropertiesDto.getSupportedTransitEncapsulation())) { throw new IllegalSwitchPropertiesException("Supported transit encapsulations should not be null or empty"); } SwitchProperties update = SwitchPropertiesMapper.INSTANCE.map(switchPropertiesDto); UpdateSwitchPropertiesResult result = transactionManager.doInTransaction(() -> { SwitchProperties switchProperties = switchPropertiesRepository.findBySwitchId(switchId) .orElseThrow(() -> new SwitchPropertiesNotFoundException(switchId)); validateSwitchProperties(switchId, update); final boolean isSwitchSyncNeeded = isSwitchSyncNeeded(switchProperties, update); switchProperties.setMultiTable(update.isMultiTable()); switchProperties.setSwitchLldp(update.isSwitchLldp()); switchProperties.setSwitchArp(update.isSwitchArp()); switchProperties.setSupportedTransitEncapsulation(update.getSupportedTransitEncapsulation()); switchProperties.setServer42FlowRtt(update.isServer42FlowRtt()); switchProperties.setServer42Port(update.getServer42Port()); switchProperties.setServer42Vlan(update.getServer42Vlan()); switchProperties.setServer42MacAddress(update.getServer42MacAddress()); return new UpdateSwitchPropertiesResult( SwitchPropertiesMapper.INSTANCE.map(switchProperties), isSwitchSyncNeeded); }); if (result.isSwitchSyncRequired()) { carrier.requestSwitchSync(switchId); } if (switchPropertiesDto.isServer42FlowRtt()) { carrier.enableServer42FlowRttOnSwitch(switchId); } else { carrier.disableServer42FlowRttOnSwitch(switchId); } return result.switchPropertiesDto; } SwitchOperationsService(RepositoryFactory repositoryFactory,
TransactionManager transactionManager,
SwitchOperationsServiceCarrier carrier); }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto) { if (isEmpty(switchPropertiesDto.getSupportedTransitEncapsulation())) { throw new IllegalSwitchPropertiesException("Supported transit encapsulations should not be null or empty"); } SwitchProperties update = SwitchPropertiesMapper.INSTANCE.map(switchPropertiesDto); UpdateSwitchPropertiesResult result = transactionManager.doInTransaction(() -> { SwitchProperties switchProperties = switchPropertiesRepository.findBySwitchId(switchId) .orElseThrow(() -> new SwitchPropertiesNotFoundException(switchId)); validateSwitchProperties(switchId, update); final boolean isSwitchSyncNeeded = isSwitchSyncNeeded(switchProperties, update); switchProperties.setMultiTable(update.isMultiTable()); switchProperties.setSwitchLldp(update.isSwitchLldp()); switchProperties.setSwitchArp(update.isSwitchArp()); switchProperties.setSupportedTransitEncapsulation(update.getSupportedTransitEncapsulation()); switchProperties.setServer42FlowRtt(update.isServer42FlowRtt()); switchProperties.setServer42Port(update.getServer42Port()); switchProperties.setServer42Vlan(update.getServer42Vlan()); switchProperties.setServer42MacAddress(update.getServer42MacAddress()); return new UpdateSwitchPropertiesResult( SwitchPropertiesMapper.INSTANCE.map(switchProperties), isSwitchSyncNeeded); }); if (result.isSwitchSyncRequired()) { carrier.requestSwitchSync(switchId); } if (switchPropertiesDto.isServer42FlowRtt()) { carrier.enableServer42FlowRttOnSwitch(switchId); } else { carrier.disableServer42FlowRttOnSwitch(switchId); } return result.switchPropertiesDto; } SwitchOperationsService(RepositoryFactory repositoryFactory,
TransactionManager transactionManager,
SwitchOperationsServiceCarrier carrier); GetSwitchResponse getSwitch(SwitchId switchId); List<GetSwitchResponse> getAllSwitches(); Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance); boolean deleteSwitch(SwitchId switchId, boolean force); void checkSwitchIsDeactivated(SwitchId switchId); void checkSwitchHasNoFlows(SwitchId switchId); void checkSwitchHasNoFlowSegments(SwitchId switchId); void checkSwitchHasNoIsls(SwitchId switchId); SwitchPropertiesDto getSwitchProperties(SwitchId switchId); SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto); PortProperties getPortProperties(SwitchId switchId, int port); Collection<SwitchConnectedDevice> getSwitchConnectedDevices(
SwitchId switchId); List<IslEndpoint> getSwitchIslEndpoints(SwitchId switchId); Switch patchSwitch(SwitchId switchId, SwitchPatch data); }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto) { if (isEmpty(switchPropertiesDto.getSupportedTransitEncapsulation())) { throw new IllegalSwitchPropertiesException("Supported transit encapsulations should not be null or empty"); } SwitchProperties update = SwitchPropertiesMapper.INSTANCE.map(switchPropertiesDto); UpdateSwitchPropertiesResult result = transactionManager.doInTransaction(() -> { SwitchProperties switchProperties = switchPropertiesRepository.findBySwitchId(switchId) .orElseThrow(() -> new SwitchPropertiesNotFoundException(switchId)); validateSwitchProperties(switchId, update); final boolean isSwitchSyncNeeded = isSwitchSyncNeeded(switchProperties, update); switchProperties.setMultiTable(update.isMultiTable()); switchProperties.setSwitchLldp(update.isSwitchLldp()); switchProperties.setSwitchArp(update.isSwitchArp()); switchProperties.setSupportedTransitEncapsulation(update.getSupportedTransitEncapsulation()); switchProperties.setServer42FlowRtt(update.isServer42FlowRtt()); switchProperties.setServer42Port(update.getServer42Port()); switchProperties.setServer42Vlan(update.getServer42Vlan()); switchProperties.setServer42MacAddress(update.getServer42MacAddress()); return new UpdateSwitchPropertiesResult( SwitchPropertiesMapper.INSTANCE.map(switchProperties), isSwitchSyncNeeded); }); if (result.isSwitchSyncRequired()) { carrier.requestSwitchSync(switchId); } if (switchPropertiesDto.isServer42FlowRtt()) { carrier.enableServer42FlowRttOnSwitch(switchId); } else { carrier.disableServer42FlowRttOnSwitch(switchId); } return result.switchPropertiesDto; } SwitchOperationsService(RepositoryFactory repositoryFactory,
TransactionManager transactionManager,
SwitchOperationsServiceCarrier carrier); GetSwitchResponse getSwitch(SwitchId switchId); List<GetSwitchResponse> getAllSwitches(); Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance); boolean deleteSwitch(SwitchId switchId, boolean force); void checkSwitchIsDeactivated(SwitchId switchId); void checkSwitchHasNoFlows(SwitchId switchId); void checkSwitchHasNoFlowSegments(SwitchId switchId); void checkSwitchHasNoIsls(SwitchId switchId); SwitchPropertiesDto getSwitchProperties(SwitchId switchId); SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto); PortProperties getPortProperties(SwitchId switchId, int port); Collection<SwitchConnectedDevice> getSwitchConnectedDevices(
SwitchId switchId); List<IslEndpoint> getSwitchIslEndpoints(SwitchId switchId); Switch patchSwitch(SwitchId switchId, SwitchPatch data); }
|
@Test public void deserializeArpWithVlanTest() throws PacketParsingException { short vlan = 1234; Ethernet ethernet = buildEthernet(srcAndDstMacAddresses, ethTypeToByteArray(EthType.VLAN_FRAME), shortToByteArray(vlan), ethTypeToByteArray(EthType.ARP), arpPacket); ArpPacketData data = service.deserializeArp(ethernet, null, 0); assertNotNull(data); assertEquals(1, data.getVlans().size()); assertEquals(Integer.valueOf(vlan), data.getVlans().get(0)); assertEquals(buildArpPacket(arpPacket), data.getArp()); }
|
@VisibleForTesting ArpPacketData deserializeArp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof ARP) { return new ArpPacketData((ARP) payload, vlans); } } catch (Exception exception) { logger.info("Could not deserialize ARP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid ARP packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting ArpPacketData deserializeArp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof ARP) { return new ArpPacketData((ARP) payload, vlans); } } catch (Exception exception) { logger.info("Could not deserialize ARP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid ARP packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting ArpPacketData deserializeArp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof ARP) { return new ArpPacketData((ARP) payload, vlans); } } catch (Exception exception) { logger.info("Could not deserialize ARP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid ARP packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting ArpPacketData deserializeArp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof ARP) { return new ArpPacketData((ARP) payload, vlans); } } catch (Exception exception) { logger.info("Could not deserialize ARP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid ARP packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
ConnectedDevicesService implements IService, IInputTranslator { @VisibleForTesting ArpPacketData deserializeArp(Ethernet eth, SwitchId switchId, long cookie) { try { List<Integer> vlans = new ArrayList<>(); IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans); if (payload instanceof ARP) { return new ArpPacketData((ARP) payload, vlans); } } catch (Exception exception) { logger.info("Could not deserialize ARP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception); return null; } logger.info("Got invalid ARP packet: {} on switch {}. Cookie {}", eth, switchId, cookie); return null; } @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.