本文整理汇总了Java中org.onosproject.net.intent.Intent类的典型用法代码示例。如果您正苦于以下问题:Java Intent类的具体用法?Java Intent怎么用?Java Intent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Intent类属于org.onosproject.net.intent包,在下文中一共展示了Intent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createIntent
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
/**
* Submits a new intent.
* Creates and submits intent from the JSON request.
*
* @param stream input JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
* @onos.rsModel IntentHost
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createIntent(InputStream stream) {
try {
IntentService service = get(IntentService.class);
ObjectNode root = (ObjectNode) mapper().readTree(stream);
Intent intent = codec(Intent.class).decode(root, this);
service.submit(intent);
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
.path("intents")
.path(intent.appId().name())
.path(Long.toString(intent.id().fingerprint()));
return Response
.created(locationBuilder.build())
.build();
} catch (IOException ioe) {
throw new IllegalArgumentException(ioe);
}
}
示例2: setUp
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
@Before
public void setUp() {
sut = new OpticalPathIntentCompiler();
coreService = createMock(CoreService.class);
expect(coreService.registerApplication("org.onosproject.net.intent"))
.andReturn(appId);
sut.coreService = coreService;
Intent.bindIdGenerator(idGenerator);
intent = OpticalPathIntent.builder()
.appId(appId)
.src(d1p1)
.dst(d3p1)
.path(new DefaultPath(PID, links, hops))
.lambda(createLambda())
.signalType(OchSignalType.FIXED_GRID)
.build();
intentExtensionService = createMock(IntentExtensionService.class);
intentExtensionService.registerCompiler(OpticalPathIntent.class, sut);
intentExtensionService.unregisterCompiler(OpticalPathIntent.class);
sut.intentManager = intentExtensionService;
replay(coreService, intentExtensionService);
}
示例3: process
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
@Override
public void process(long sid, ObjectNode payload) {
int appId = Integer.parseInt(string(payload, APP_ID));
String appName = string(payload, APP_NAME);
ApplicationId applicId = new DefaultApplicationId(appId, appName);
long intentKey = Long.decode(string(payload, KEY));
Key key = Key.of(intentKey, applicId);
log.debug("Attempting to select intent key={}", key);
Intent intent = intentService.getIntent(key);
if (intent == null) {
log.debug("no such intent found!");
} else {
log.debug("starting to monitor intent {}", key);
traffic.monitor(intent);
}
}
示例4: corruptPoll
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
/**
* Trigger resubmit of intent in CORRUPT during periodic poll.
*/
@Test
public void corruptPoll() {
IntentStoreDelegate mockDelegate = new IntentStoreDelegate() {
@Override
public void process(IntentData intentData) {
intentData.setState(CORRUPT);
store.write(intentData);
}
@Override
public void notify(IntentEvent event) {}
};
store.setDelegate(mockDelegate);
Intent intent = new MockIntent(1L);
Timestamp version = new SystemClockTimestamp(1L);
IntentData data = new IntentData(intent, INSTALL_REQ, version);
store.addPending(data);
cleanup.run(); //FIXME broken?
assertEquals("Expect number of submits incorrect",
1, service.submitCounter());
}
示例5: pendingPoll
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
/**
* Trigger resubmit of intent in INSTALL_REQ for too long.
*/
@Test
public void pendingPoll() {
IntentStoreDelegate mockDelegate = new IntentStoreDelegate() {
@Override
public void process(IntentData intentData) {}
@Override
public void notify(IntentEvent event) {
cleanup.event(event);
}
};
store.setDelegate(mockDelegate);
Intent intent = new MockIntent(1L);
Timestamp version = new SystemClockTimestamp(1L);
IntentData data = new IntentData(intent, INSTALL_REQ, version);
store.addPending(data);
cleanup.run();
assertEquals("Expect number of submits incorrect",
1, service.submitCounter());
}
示例6: setUp
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
@Before
public void setUp() {
provider = new PtToPtIntentVirtualNetworkProvider();
provider.providerRegistry = virtualNetworkRegistry;
final CoreService mockCoreService = createMock(CoreService.class);
provider.coreService = mockCoreService;
expect(mockCoreService.registerApplication(PtToPtIntentVirtualNetworkProvider.PTPT_INTENT_APPID))
.andReturn(APP_ID).anyTimes();
replay(mockCoreService);
Intent.unbindIdGenerator(idGenerator);
Intent.bindIdGenerator(idGenerator);
intentService.addListener(listener);
provider.intentService = intentService;
// Register a compiler and an installer both setup for success.
intentExtensionService = intentService;
intentExtensionService.registerCompiler(PointToPointIntent.class, compiler);
provider.activate();
created = new Semaphore(0, true);
removed = new Semaphore(0, true);
}
示例7: setUp
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
@Before
public void setUp() {
service = new MockIntentService();
store = new SimpleIntentStore();
cleanup = new IntentCleanup();
idGenerator = new MockIdGenerator();
cleanup.cfgService = new ComponentConfigAdapter();
cleanup.service = service;
cleanup.store = store;
cleanup.period = 10;
cleanup.retryThreshold = 3;
cleanup.activate();
assertTrue("store should be empty",
Sets.newHashSet(cleanup.store.getIntents()).isEmpty());
Intent.bindIdGenerator(idGenerator);
}
示例8: generateIntents
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
private Collection<Intent> generateIntents() {
List<Host> hosts = Lists.newArrayList(hostService.getHosts());
List<Intent> fullMesh = Lists.newArrayList();
for (int i = 0; i < hosts.size(); i++) {
for (int j = i + 1; j < hosts.size(); j++) {
fullMesh.add(HostToHostIntent.builder()
.appId(appId())
.one(hosts.get(i).id())
.two(hosts.get(j).id())
.build());
}
}
Collections.shuffle(fullMesh);
return fullMesh.subList(0, Math.min(count, fullMesh.size()));
}
示例9: submitIntents
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
private void submitIntents(List<Intent> intents) {
latch = new CountDownLatch(count);
log.info("CountDownLatch is set with count of {}", count);
start = System.currentTimeMillis();
for (Intent intent : intents) {
if (add) {
service.submit(intent);
} else {
service.withdraw(intent);
}
}
try {
if (latch.await(1000 + count * 30, TimeUnit.MILLISECONDS)) {
printResults(count);
} else {
print("Failure: %d intents not installed", latch.getCount());
}
} catch (InterruptedException e) {
print(e.toString());
}
}
示例10: execute
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
@Override
protected void execute() {
IntentService service = get(IntentService.class);
ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
TrafficSelector selector = buildTrafficSelector();
TrafficTreatment treatment = buildTrafficTreatment();
List<Constraint> constraints = buildConstraints();
Intent intent = PointToPointIntent.builder()
.appId(appId())
.key(key())
.selector(selector)
.treatment(treatment)
.ingressPoint(ingress)
.egressPoint(egress)
.constraints(constraints)
.priority(priority())
.build();
service.submit(intent);
print("Point to point intent submitted:\n%s", intent.toString());
}
示例11: setUp
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
@Before
public void setUp() {
AbstractProjectableModel.setDriverService(null, new MockDriverService());
sut = new OpticalOduIntentCompiler();
coreService = createMock(CoreService.class);
expect(coreService.registerApplication("org.onosproject.net.intent"))
.andReturn(appId);
sut.coreService = coreService;
sut.deviceService = new MockDeviceService();
sut.resourceService = new MockResourceService();
sut.topologyService = new MockTopologyService();
Intent.bindIdGenerator(idGenerator);
intentExtensionService = createMock(IntentExtensionService.class);
intentExtensionService.registerCompiler(OpticalOduIntent.class, sut);
intentExtensionService.unregisterCompiler(OpticalOduIntent.class);
sut.intentManager = intentExtensionService;
replay(coreService, intentExtensionService);
}
示例12: removeConnectivity
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
@Override
public boolean removeConnectivity(OpticalConnectivityId id) {
log.info("removeConnectivity({})", id);
OpticalConnectivity connectivity = connectivities.remove(id);
if (connectivity == null) {
log.info("OpticalConnectivity with id {} not found.", id);
return false;
}
// TODO withdraw intent only if all of connectivities that use the optical path are withdrawn
connectivity.getRealizingLinks().forEach(l -> {
Intent intent = intentService.getIntent(l.realizingIntentKey());
intentService.withdraw(intent);
});
return true;
}
示例13: updateCrossConnectLink
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
private void updateCrossConnectLink(Intent intent) {
linkPathMap.entrySet().stream()
.filter(e -> e.getKey().realizingIntentKey().equals(intent.key()))
.forEach(e -> {
ConnectPoint packetSrc = e.getKey().src();
ConnectPoint packetDst = e.getKey().dst();
Bandwidth bw = e.getKey().bandwidth();
// Updates bandwidth of packet ports
updatePortBandwidth(packetSrc, bw);
updatePortBandwidth(packetDst, bw);
OpticalConnectivity connectivity = e.getValue();
connectivity.setLinkEstablished(packetSrc, packetDst);
if (e.getValue().isAllRealizingLinkEstablished()) {
updateBandwidthUsage(connectivity);
// Notifies listeners if all links are established
post(new OpticalPathEvent(OpticalPathEvent.Type.PATH_INSTALLED, e.getValue().id()));
}
});
}
示例14: withdrawIntent
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
@Test
public void withdrawIntent() {
flowRuleService.setFuture(true);
listener.setLatch(1, Type.INSTALLED);
Intent intent = new MockIntent(MockIntent.nextId());
service.submit(intent);
listener.await(Type.INSTALLED);
assertEquals(1L, service.getIntentCount());
assertEquals(1L, flowRuleService.getFlowRuleCount());
listener.setLatch(1, Type.WITHDRAWN);
service.withdraw(intent);
listener.await(Type.WITHDRAWN);
assertEquals(0L, flowRuleService.getFlowRuleCount());
verifyState();
}
示例15: removeIntents
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
@Override
public void removeIntents() {
if (!isElectedLeader) {
// Only leader will withdraw intents
return;
}
log.debug("Intent Synchronizer shutdown: withdrawing all intents...");
for (Entry<Key, Intent> entry : intents.entrySet()) {
intentService.withdraw(entry.getValue());
log.debug("Intent Synchronizer withdrawing intent: {}",
entry.getValue());
}
intents.clear();
log.info("Tried to clean all intents");
}