use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class McastConfigTest method setUp.
/**
* Initialize test related variables.
*
* @throws Exception
*/
@Before
public void setUp() throws Exception {
InputStream jsonStream = McastConfigTest.class.getResourceAsStream("/mcast-config.json");
InputStream invalidJsonStream = McastConfigTest.class.getResourceAsStream("/mcast-config-invalid.json");
InputStream jsonStreamForInnerVlan = McastConfigTest.class.getResourceAsStream("/mcast-config-inner.json");
InputStream invalidJsonStreamForInnerVlan = McastConfigTest.class.getResourceAsStream("/mcast-config-invalid-inner.json");
ApplicationId subject = APP_ID;
String key = CoreService.CORE_APP_NAME;
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readTree(jsonStream);
JsonNode invalidJsonNode = mapper.readTree(invalidJsonStream);
JsonNode jsonNodeForInnerVlan = mapper.readTree(jsonStreamForInnerVlan);
JsonNode invalidJsonNodeForInnerVlan = mapper.readTree(invalidJsonStreamForInnerVlan);
ConfigApplyDelegate delegate = new MockDelegate();
config = new McastConfig();
config.init(subject, key, jsonNode, mapper, delegate);
invalidConfig = new McastConfig();
invalidConfig.init(subject, key, invalidJsonNode, mapper, delegate);
configForInnerVlan = new McastConfig();
configForInnerVlan.init(subject, key, jsonNodeForInnerVlan, mapper, delegate);
invalidConfigForInnerVlan = new McastConfig();
invalidConfigForInnerVlan.init(subject, key, invalidJsonNodeForInnerVlan, mapper, delegate);
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class SubjectFactoriesTest method testAppIdFactory.
@Test
public void testAppIdFactory() {
SubjectFactory<ApplicationId> appIdFactory = SubjectFactories.APP_SUBJECT_FACTORY;
assertThat(appIdFactory, notNullValue());
ApplicationId id = NetTestTools.APP_ID;
ApplicationId createdAppId = appIdFactory.createSubject(id.name());
assertThat(createdAppId.id(), equalTo(id.id()));
assertThat(appIdFactory.subjectKey(id), is(id.name()));
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class BandwidthProfileTest method testMeterConversion.
@Test
public void testMeterConversion() {
DeviceId deviceId = DeviceId.deviceId("netconf:10.0.0.1:22");
ApplicationId appId = TestApplicationId.create("org.onosproject.foo.app");
Meter.Builder meterBuilder = new DefaultMeter.Builder().withId(MeterId.meterId(ONE)).withUnit(Meter.Unit.KB_PER_SEC).forDevice(deviceId).burst();
// Create Meter with single band
Band band1 = DefaultBand.builder().ofType(Band.Type.DROP).withRate(TEN_M).burstSize(TWO_K).build();
Meter meter = meterBuilder.fromApp(appId).withBands(Arrays.asList(band1)).build();
BandwidthProfile bandwidthProfile = BandwidthProfile.fromMeter(meter);
assertEquals("wrong bw profile name", bandwidthProfile.name(), meter.id().toString());
assertEquals("wrong bw profile type", bandwidthProfile.type(), BandwidthProfile.Type.sr2CM);
assertEquals("wrong bw profile CIR", bandwidthProfile.cir().bps(), band1.rate() * EIGHT_K, 0);
assertEquals("wrong bw profile CBS", (long) bandwidthProfile.cbs(), (long) band1.burst());
assertNull(bandwidthProfile.pir());
assertNull(bandwidthProfile.pbs());
assertNull(bandwidthProfile.ebs());
assertEquals("wrong green action", bandwidthProfile.greenAction(), getBuilder(Action.PASS).build());
assertNull(bandwidthProfile.yellowAction());
assertEquals("wrong red action", bandwidthProfile.redAction(), getBuilder(Action.DISCARD).build());
assertEquals("wrong color-aware mode", bandwidthProfile.colorAware(), false);
// Create Meter with two bands
Band band2 = DefaultBand.builder().burstSize(ONE_K).ofType(Band.Type.REMARK).dropPrecedence((short) 0b001010).withRate(ONE_M).build();
meter = meterBuilder.fromApp(appId).withBands(Arrays.asList(band1, band2)).build();
bandwidthProfile = BandwidthProfile.fromMeter(meter);
assertEquals("wrong bw profile name", bandwidthProfile.name(), meter.id().toString());
assertEquals("wrong bw profile type", bandwidthProfile.type(), BandwidthProfile.Type.trTCM);
assertEquals("wrong bw profile CIR", bandwidthProfile.cir().bps(), band2.rate() * EIGHT_K, 0);
assertEquals("wrong bw profile CBS", (long) bandwidthProfile.cbs(), (long) band2.burst());
assertEquals("wrong bw profile PIR", bandwidthProfile.pir().bps(), band1.rate() * EIGHT_K, 0);
assertEquals("wrong bw profile PBS", (long) bandwidthProfile.pbs(), (long) band1.burst());
assertNull(bandwidthProfile.ebs());
assertEquals("wrong green action", bandwidthProfile.greenAction(), getBuilder(Action.PASS).build());
assertEquals("wrong yellow action", bandwidthProfile.yellowAction(), getBuilder(Action.REMARK).dscpClass(DscpClass.AF11).build());
assertEquals("wrong red action", bandwidthProfile.redAction(), getBuilder(Action.DISCARD).build());
assertEquals("wrong color-aware mode", bandwidthProfile.colorAware(), false);
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class DistributedSecurityModeStoreTest method setUp.
@Before
public void setUp() throws Exception {
appId = new DefaultApplicationId(1, "test");
testPermissions = new HashSet<Permission>();
testPermission = new Permission("testClass", "testName");
testPermissions.add(testPermission);
testFeatures = new ArrayList<String>();
testFeatures.add("testFeature");
testRequiredApps = new ArrayList<String>();
testRequiredApps.add("testRequiredApp");
app = DefaultApplication.builder().withAppId(appId).withVersion(Version.version(1, 1, "patch", "build")).withTitle("testTitle").withDescription("testDes").withOrigin("testOri").withCategory("testCT").withUrl("testurl").withReadme("test").withIcon(null).withRole(ApplicationRole.ADMIN).withPermissions(testPermissions).withFeaturesRepo(Optional.ofNullable(null)).withFeatures(testFeatures).withRequiredApps(testRequiredApps).build();
testLocations = new HashSet<String>();
testLocations.add("locationA");
testLocations.add("locationB");
Set<ApplicationId> appIdSet = new HashSet<ApplicationId>();
appIdSet.add(appId);
localBundleAppDirectory = new ConcurrentHashMap<>();
localBundleAppDirectory.put("testLocation", appIdSet);
localAppBundleDirectory = new ConcurrentHashMap<>();
localAppBundleDirectory.put(appId, testLocations);
violations = new ConcurrentHashMap<ApplicationId, Set<Permission>>();
violations.put(appId, testPermissions);
testSecInfo = new SecurityInfo(testPermissions, SECURED);
states = new ConcurrentHashMap<ApplicationId, SecurityInfo>();
states.put(appId, testSecInfo);
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class DistributedApplicationStore method activate.
@Activate
public void activate() {
messageHandlingExecutor = newSingleThreadExecutor(groupedThreads("onos/store/app", "message-handler", log));
clusterCommunicator.addSubscriber(APP_BITS_REQUEST, bytes -> new String(bytes, Charsets.UTF_8), name -> {
try {
log.info("Sending bits for application {}", name);
return toByteArray(getApplicationInputStream(name));
} catch (ApplicationException e) {
log.warn("Bits for application {} are not available on this node yet", name);
return null;
} catch (IOException e) {
throw new StorageException(e);
}
}, Function.identity(), messageHandlingExecutor);
apps = storageService.<ApplicationId, InternalApplicationHolder>consistentMapBuilder().withName("onos-apps").withRelaxedReadConsistency().withSerializer(Serializer.using(KryoNamespaces.API, InternalApplicationHolder.class, InternalState.class)).withVersion(versionService.version()).withRevisionType(RevisionType.PROPAGATE).withCompatibilityFunction(this::convertApplication).build();
/* To update the version in application store if it does not matche with the local system.
This will happen only when upgrading onos using issu or during rollback if upgrade does not work.
*/
apps.asJavaMap().forEach((appId, holder) -> apps.asJavaMap().put(appId, convertApplication(holder, versionService.version())));
appActivationTopic = storageService.<Application>topicBuilder().withName("onos-apps-activation-topic").withSerializer(Serializer.using(KryoNamespaces.API)).withVersion(versionService.version()).withRevisionType(RevisionType.PROPAGATE).withCompatibilityFunction(this::convertApplication).build();
activationExecutor = newSingleThreadExecutor(groupedThreads("onos/store/app", "app-activation", log));
appActivationTopic.subscribe(appActivator, activationExecutor);
executor = newSingleThreadScheduledExecutor(groupedThreads("onos/app", "store", log));
statusChangeListener = status -> {
if (status == Status.ACTIVE) {
executor.execute(this::bootstrapExistingApplications);
}
};
apps.addListener(appsListener, activationExecutor);
apps.addStatusChangeListener(statusChangeListener);
coreAppId = getId(CoreService.CORE_APP_NAME);
downloadMissingApplications();
activateExistingApplications();
log.info("Started");
}
Aggregations