本文整理汇总了Java中net.floodlightcontroller.core.internal.RoleChanger.RoleChangeTask类的典型用法代码示例。如果您正苦于以下问题:Java RoleChangeTask类的具体用法?Java RoleChangeTask怎么用?Java RoleChangeTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RoleChangeTask类属于net.floodlightcontroller.core.internal.RoleChanger包,在下文中一共展示了RoleChangeTask类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testRoleChangeTask
import net.floodlightcontroller.core.internal.RoleChanger.RoleChangeTask; //导入依赖的package包/类
@Test
public void testRoleChangeTask() {
@SuppressWarnings("unchecked")
Collection<OFSwitchImpl> switches =
EasyMock.createMock(Collection.class);
long now = System.nanoTime();
long dt1 = 10 * 1000*1000*1000L;
long dt2 = 20 * 1000*1000*1000L;
long dt3 = 15 * 1000*1000*1000L;
RoleChangeTask t1 = new RoleChangeTask(switches, null, now+dt1);
RoleChangeTask t2 = new RoleChangeTask(switches, null, now+dt2);
RoleChangeTask t3 = new RoleChangeTask(switches, null, now+dt3);
// FIXME: cannot test comparison against self. grrr
//assertTrue( t1.compareTo(t1) <= 0 );
assertTrue( t1.compareTo(t2) < 0 );
assertTrue( t1.compareTo(t3) < 0 );
assertTrue( t2.compareTo(t1) > 0 );
//assertTrue( t2.compareTo(t2) <= 0 );
assertTrue( t2.compareTo(t3) > 0 );
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:23,代码来源:RoleChangerTest.java
示例2: testRoleChangeTask
import net.floodlightcontroller.core.internal.RoleChanger.RoleChangeTask; //导入依赖的package包/类
@Test
public void testRoleChangeTask() {
@SuppressWarnings("unchecked")
Collection<IOFSwitch> switches =
EasyMock.createMock(Collection.class);
long now = System.nanoTime();
long dt1 = 10 * 1000*1000*1000L;
long dt2 = 20 * 1000*1000*1000L;
long dt3 = 15 * 1000*1000*1000L;
RoleChangeTask t1 = new RoleChangeTask(switches, null, now+dt1);
RoleChangeTask t2 = new RoleChangeTask(switches, null, now+dt2);
RoleChangeTask t3 = new RoleChangeTask(switches, null, now+dt3);
// FIXME: cannot test comparison against self. grrr
//assertTrue( t1.compareTo(t1) <= 0 );
assertTrue( t1.compareTo(t2) < 0 );
assertTrue( t1.compareTo(t3) < 0 );
assertTrue( t2.compareTo(t1) > 0 );
//assertTrue( t2.compareTo(t2) <= 0 );
assertTrue( t2.compareTo(t3) > 0 );
}
开发者ID:dana-i2cat,项目名称:floodlight-nfv,代码行数:23,代码来源:RoleChangerTest.java
示例3: testSubmitRequest
import net.floodlightcontroller.core.internal.RoleChanger.RoleChangeTask; //导入依赖的package包/类
@Test
public void testSubmitRequest() throws Exception {
LinkedList<OFSwitchImpl> switches = new LinkedList<OFSwitchImpl>();
roleChanger.timeout = 500*1000*1000; // 500 ms
// a switch that supports role requests
OFSwitchImpl sw1 = EasyMock.createStrictMock(OFSwitchImpl.class);
// No support for NX_ROLE
expect(sw1.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE))
.andReturn(true);
expect(sw1.sendNxRoleRequest(EasyMock.same(Role.MASTER), EasyMock.anyLong()))
.andReturn(1);
expect(sw1.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE))
.andReturn(true);
expect(sw1.sendNxRoleRequest(EasyMock.same(Role.SLAVE), EasyMock.anyLong()))
.andReturn(1);
// The following calls happen for timeout handling:
expect(sw1.checkFirstPendingRoleRequestCookie(EasyMock.anyLong()))
.andReturn(false);
expect(sw1.checkFirstPendingRoleRequestCookie(EasyMock.anyLong()))
.andReturn(false);
switches.add(sw1);
replay(sw1);
roleChanger.submitRequest(switches, Role.MASTER);
roleChanger.submitRequest(switches, Role.SLAVE);
// Wait until role request has been sent.
// TODO: need to get rid of this sleep somehow
Thread.sleep(100);
// Now there should be exactly one timeout task pending
assertEquals(2, roleChanger.pendingTasks.size());
// Make sure it's indeed a timeout task
assertSame(RoleChanger.RoleChangeTask.Type.TIMEOUT,
roleChanger.pendingTasks.peek().type);
// Check that RoleChanger indeed made a copy of switches collection
assertNotSame(switches, roleChanger.pendingTasks.peek().switches);
// Wait until the timeout triggers
// TODO: get rid of this sleep too.
Thread.sleep(500);
assertEquals(0, roleChanger.pendingTasks.size());
verify(sw1);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:46,代码来源:RoleChangerTest.java
示例4: testErrorEPERM
import net.floodlightcontroller.core.internal.RoleChanger.RoleChangeTask; //导入依赖的package包/类
@Test
public void testErrorEPERM() throws Exception {
// Check behavior with a BAD_REQUEST/EPERM error
// Ensure controller attempts to reset switch role.
OFChannelState state = new OFChannelState();
state.hsState = HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
OFError error = new OFError();
error.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
error.setErrorCode(OFBadRequestCode.OFPBRC_EPERM);
IOFSwitch sw = createMock(IOFSwitch.class);
chdlr.sw = sw;
controller.activeSwitches.put(1L, sw);
// prepare the switch and lock expectations
Lock lock = createNiceMock(Lock.class);
expect(sw.getListenerReadLock()).andReturn(lock).anyTimes();
expect(sw.isConnected()).andReturn(true).anyTimes();
expect(sw.getHARole()).andReturn(Role.MASTER).anyTimes();
expect(sw.getId()).andReturn(1L).anyTimes();
// Make sure controller attempts to reset switch master
expect(sw.getAttribute("supportsNxRole")).andReturn(true).anyTimes();
expect(sw.getNextTransactionId()).andReturn(0).anyTimes();
sw.write(EasyMock.<List<OFMessage>> anyObject(),
(FloodlightContext)anyObject());
// test
replay(sw, lock);
chdlr.processOFMessage(error);
DelayQueue<RoleChangeTask> pendingTasks =
controller.roleChanger.pendingTasks;
synchronized (pendingTasks) {
RoleChangeTask t;
while ((t = pendingTasks.peek()) == null ||
RoleChanger.RoleChangeTask.Type.TIMEOUT != t.type) {
pendingTasks.wait();
}
}
// Now there should be exactly one timeout task pending
assertEquals(1, pendingTasks.size());
}
开发者ID:dana-i2cat,项目名称:floodlight-nfv,代码行数:43,代码来源:ControllerTest.java
示例5: testSubmitRequest
import net.floodlightcontroller.core.internal.RoleChanger.RoleChangeTask; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testSubmitRequest() throws Exception {
LinkedList<IOFSwitch> switches = new LinkedList<IOFSwitch>();
roleChanger.timeout = 100*1000*1000; // 100 ms
// a switch that supports role requests
IOFSwitch sw1 = EasyMock.createStrictMock(IOFSwitch.class);
// Support for NX_ROLE
expect(sw1.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE))
.andReturn(true);
expect(sw1.getNextTransactionId()).andReturn(1);
sw1.write((List<OFMessage>)EasyMock.anyObject(),
(FloodlightContext)EasyMock.anyObject());
// Second request
expect(sw1.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE))
.andReturn(true);
expect(sw1.getNextTransactionId()).andReturn(2);
sw1.write((List<OFMessage>)EasyMock.anyObject(),
(FloodlightContext)EasyMock.anyObject());
expect(sw1.getAttribute(IOFSwitch.SWITCH_DESCRIPTION_DATA))
.andReturn(null);
expect(sw1.getHARole()).andReturn(null);
sw1.setHARole(Role.MASTER, false);
expect(sw1.getAttribute(IOFSwitch.SWITCH_DESCRIPTION_DATA))
.andReturn(null);
expect(sw1.getHARole()).andReturn(Role.MASTER);
sw1.setHARole(Role.SLAVE, false);
// Disconnect on timing out SLAVE request
sw1.disconnectOutputStream();
switches.add(sw1);
// Add to switch when timing out the MASTER request
controller.addSwitch(sw1, true);
replay(sw1, controller);
roleChanger.submitRequest(switches, Role.MASTER);
roleChanger.submitRequest(switches, Role.SLAVE);
// Wait until role request has been sent.
synchronized (roleChanger.pendingTasks) {
while (RoleChanger.RoleChangeTask.Type.TIMEOUT !=
roleChanger.pendingTasks.peek().type) {
roleChanger.pendingTasks.wait();
}
}
// Now there should be exactly one timeout task pending for each request
assertEquals(2, roleChanger.pendingTasks.size());
// Check that RoleChanger indeed made a copy of switches collection
assertNotSame(switches, roleChanger.pendingTasks.peek().switches);
// Wait until the timeout triggers
synchronized (roleChanger.pendingTasks) {
while (roleChanger.pendingTasks.size() != 0) {
roleChanger.pendingTasks.wait();
}
}
verify(sw1, controller);
}
开发者ID:dana-i2cat,项目名称:floodlight-nfv,代码行数:61,代码来源:RoleChangerTest.java
注:本文中的net.floodlightcontroller.core.internal.RoleChanger.RoleChangeTask类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论