本文整理汇总了Java中org.onosproject.net.intent.Intent类的典型用法代码示例。如果您正苦于以下问题:Java Intent类的具体用法?Java Intent怎么用?Java Intent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Intent类属于org.onosproject.net.intent包,在下文中一共展示了Intent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:IntentsWebResource.java
示例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);
}
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:OpticalPathIntentCompilerTest.java
示例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);
}
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:TopologyViewMessageHandler.java
示例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());
}
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:IntentCleanupTest.java
示例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());
}
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:IntentCleanupTest.java
示例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);
}
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:PtToPtIntentVirtualNetworkProviderTest.java
示例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);
}
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:IntentCleanupTest.java
示例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()));
}
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:RandomIntentCommand.java
示例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());
}
}
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:IntentPushTestCommand.java
示例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());
}
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:AddPointToPointIntentCommand.java
示例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);
}
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:OpticalOduIntentCompilerTest.java
示例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;
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:OpticalPathProvisioner.java
示例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()));
}
});
}
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:OpticalPathProvisioner.java
示例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();
}
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:IntentManagerTest.java
示例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");
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:IntentSynchronizer.java
示例16: setUp
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
@Before
public void setUp() {
processor = createMock(IntentProcessor.class);
version = createMock(Timestamp.class);
idGenerator = new MockIdGenerator();
Intent.bindIdGenerator(idGenerator);
// Intent creation should be placed after binding an ID generator
input = PointToPointIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
compiled = PathIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.path(path)
.build();
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:CompilingTest.java
示例17: testBandwidthConstrainedIntentSuccess
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
/**
* Tests that requests with sufficient available bandwidth succeed.
*/
@Test
public void testBandwidthConstrainedIntentSuccess() {
final ResourceService resourceService =
IntentTestsMocks.MockResourceService.makeBandwidthResourceService(1000.0);
final List<Constraint> constraints =
Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(100.0)));
final PointToPointIntent intent = makeIntent("s1", "s3", constraints);
String[] hops = {"s1", "s2", "s3"};
final PointToPointIntentCompiler compiler = makeCompiler(hops, resourceService);
final List<Intent> compiledIntents = compiler.compile(intent, null);
assertThat(compiledIntents, Matchers.notNullValue());
assertThat(compiledIntents, hasSize(1));
}
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:PointToPointIntentCompilerTest.java
示例18: verifyState
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
public void verifyState() {
// verify that all intents are parked and the batch operation is unblocked
Set<IntentState> parked = Sets.newHashSet(INSTALLED, WITHDRAWN, FAILED, CORRUPT);
for (Intent i : service.getIntents()) {
IntentState state = service.getIntentState(i.key());
assertTrue("Intent " + i.id() + " is in invalid state " + state,
parked.contains(state));
}
//the batch has not yet been removed when we receive the last event
// FIXME: this doesn't guarantee to avoid the race
//FIXME
// for (int tries = 0; tries < 10; tries++) {
// if (manager.batchService.getPendingOperations().isEmpty()) {
// break;
// }
// delay(10);
// }
// assertTrue("There are still pending batch operations.",
// manager.batchService.getPendingOperations().isEmpty());
}
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:IntentManagerTest.java
示例19: corruptEvent
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
/**
* Verify resubmit in response to CORRUPT event.
*/
@Test
public void corruptEvent() {
IntentStoreDelegate mockDelegate = new IntentStoreDelegate() {
@Override
public void process(IntentData intentData) {
intentData.setState(CORRUPT);
store.write(intentData);
}
@Override
public void notify(IntentEvent event) {
cleanup.event(event);
}
};
store.setDelegate(mockDelegate);
Intent intent = new MockIntent(1L);
IntentData data = new IntentData(intent, INSTALL_REQ, null);
store.addPending(data);
assertEquals("Expect number of submits incorrect",
1, service.submitCounter());
}
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:IntentCleanupTest.java
示例20: testFourInterfacesTwoHostEventsDifferentVlan
import org.onosproject.net.intent.Intent; //导入依赖的package包/类
/**
* Checks the case in which six ports are configured with VLANs and
* initially no hosts are registered by the HostService. The first three
* ports have an interface configured on VLAN1, the other three have an
* interface configured on VLAN2. When the module starts up, two hosts -
* on device one and four - port 1 (VLAN 1 and VLAN 2), are registered by
* the HostService and events are sent to the application. sp2mp intents
* are created for all interfaces configured and no mp2sp intents are created
* at all, since the minimum number of hosts needed on the same vlan to
* create mp2sp intents is 2.
* The number of intents expected is six: three for VLAN1, three for VLAN2.
* six sp2mp intents, zero mp2sp intents. IPs are added on the first host
* only to demonstrate it doesn't influence the number of intents created.
*/
@Test
public void testFourInterfacesTwoHostEventsDifferentVlan() {
vpls.activate();
Host h1 = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(1),
Collections.singleton(IP1));
Host h4 = new DefaultHost(PID, HID4, MAC4, VLAN2, getLocation(4),
Collections.EMPTY_SET);
hostsAvailable.addAll(Sets.newHashSet(h1, h4));
hostsAvailable.forEach(host -> {
hostListener.event(new HostEvent(HostEvent.Type.HOST_ADDED, host));
});
List<Intent> expectedIntents = new ArrayList<>();
expectedIntents.addAll(generateVlanOneBrc());
expectedIntents.addAll(generateVlanTwoBrc());
checkIntents(expectedIntents);
}
开发者ID:shlee89,项目名称:athena,代码行数:35,代码来源:VplsTest.java
注:本文中的org.onosproject.net.intent.Intent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论