本文整理汇总了Java中org.openflow.protocol.OFType类的典型用法代码示例。如果您正苦于以下问题:Java OFType类的具体用法?Java OFType怎么用?Java OFType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OFType类属于org.openflow.protocol包,在下文中一共展示了OFType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: clearFlowMods
import org.openflow.protocol.OFType; //导入依赖的package包/类
/**
* @param sw
* The switch we wish to remove flows from
* @param match
* The specific OFMatch object of specific flows we wish to
* delete
* @param outPort
* The specific Output Action OutPort of specific flows we wish
* to delete
*/
public void clearFlowMods(IOFSwitch sw, OFMatch match, Short outPort) {
// Delete pre-existing flows with the same match, and output action port
// or outPort
match.setWildcards(OFMatch.OFPFW_ALL);
OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.FLOW_MOD)).setMatch(match)
.setCommand(OFFlowMod.OFPFC_DELETE)
.setOutPort(outPort)
.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
try {
List<OFMessage> msglist = new ArrayList<OFMessage>(1);
msglist.add(fm);
sw.write(msglist, cntx);
} catch (Exception e) {
log.error("Failed to clear flows on switch {} - {}", this, e);
}
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:28,代码来源:PortDownReconciliation.java
示例2: addFlowReconcileListener
import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public synchronized void addFlowReconcileListener(
IFlowReconcileListener listener) {
flowReconcileListeners.addListener(OFType.FLOW_MOD, listener);
if (logger.isTraceEnabled()) {
StringBuffer sb = new StringBuffer();
sb.append("FlowMod listeners: ");
for (IFlowReconcileListener l :
flowReconcileListeners.getOrderedListeners()) {
sb.append(l.getName());
sb.append(",");
}
logger.trace(sb.toString());
}
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:17,代码来源:FlowReconcileManager.java
示例3: init
import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
threadPool = context.getServiceImpl(IThreadPoolService.class);
counterStore = context.getServiceImpl(ICounterStoreService.class);
debugCounters = context.getServiceImpl(IDebugCounterService.class);
flowQueue = new PriorityPendingQueue<OFMatchReconcile>();
flowReconcileListeners =
new ListenerDispatcher<OFType, IFlowReconcileListener>();
Map<String, String> configParam = context.getConfigParams(this);
String enableValue = configParam.get(EnableConfigKey);
registerFlowReconcileManagerDebugCounters();
// Set flowReconcile default to true
flowReconcileEnabled = true;
if (enableValue != null &&
enableValue.equalsIgnoreCase("false")) {
flowReconcileEnabled = false;
}
flowReconcileThreadRunCount = new AtomicInteger(0);
lastReconcileTime = new Date(0);
logger.debug("FlowReconcile is {}", flowReconcileEnabled);
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:24,代码来源:FlowReconcileManager.java
示例4: init
import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
restApi = context.getServiceImpl(IRestApiService.class);
counterStore = context.getServiceImpl(ICounterStoreService.class);
deviceManager = context.getServiceImpl(IDeviceService.class);
routingEngine = context.getServiceImpl(IRoutingService.class);
topology = context.getServiceImpl(ITopologyService.class);
sfp = context.getServiceImpl(IStaticFlowEntryPusherService.class);
messageDamper = new OFMessageDamper(OFMESSAGE_DAMPER_CAPACITY,
EnumSet.of(OFType.FLOW_MOD),
OFMESSAGE_DAMPER_TIMEOUT);
vips = new HashMap<String, LBVip>();
pools = new HashMap<String, LBPool>();
members = new HashMap<String, LBMember>();
vipIpToId = new HashMap<Integer, String>();
vipIpToMac = new HashMap<Integer, MACAddress>();
memberIpToId = new HashMap<Integer, String>();
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:23,代码来源:LoadBalancer.java
示例5: startUp
import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void startUp(FloodlightModuleContext context) {
clearCurrentTopology();
// Initialize role to floodlight provider role.
this.role = floodlightProvider.getRole();
ScheduledExecutorService ses = threadPool.getScheduledExecutor();
newInstanceTask = new SingletonTask(ses, new UpdateTopologyWorker());
if (role != Role.SLAVE)
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS,
TimeUnit.MILLISECONDS);
linkDiscovery.addListener(this);
floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
floodlightProvider.addHAListener(this.haListener);
addRestletRoutable();
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:19,代码来源:TopologyManager.java
示例6: moveToWaitHello
import org.openflow.protocol.OFType; //导入依赖的package包/类
@Test
public void moveToWaitHello() throws Exception {
resetChannel();
channel.write(capture(writeCapture));
expectLastCall().andReturn(null).once();
replay(channel);
// replay unused mocks
replay(messageEvent);
handler.channelConnected(ctx, channelStateEvent);
List<OFMessage> msgs = getMessagesFromCapture();
assertEquals(1, msgs.size());
assertEquals(OFType.HELLO, msgs.get(0).getType());
assertEquals(OFChannelHandler.ChannelState.WAIT_HELLO,
handler.getStateForTesting());
verifyUniqueXids(msgs);
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:19,代码来源:OFChannelHandlerTest.java
示例7: write
import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void write(OFMessage m, FloodlightContext bc) {
if (channel == null || !isConnected())
return;
//throws IOException {
Map<IOFSwitch,List<OFMessage>> msg_buffer_map = local_msg_buffer.get();
List<OFMessage> msg_buffer = msg_buffer_map.get(this);
if (msg_buffer == null) {
msg_buffer = new ArrayList<OFMessage>();
msg_buffer_map.put(this, msg_buffer);
}
this.floodlightProvider.handleOutgoingMessage(this, m, bc);
msg_buffer.add(m);
if ((msg_buffer.size() >= Controller.BATCH_MAX_SIZE) ||
((m.getType() != OFType.PACKET_OUT) && (m.getType() != OFType.FLOW_MOD))) {
this.write(msg_buffer);
msg_buffer.clear();
}
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:22,代码来源:OFSwitchBase.java
示例8: clearAllFlowMods
import org.openflow.protocol.OFType; //导入依赖的package包/类
@LogMessageDoc(level="INFO",
message="Switch {switch} flow cleared",
explanation="The switch flow table has been cleared, " +
"this normally happens on switch connection")
@Override
public void clearAllFlowMods() {
if (channel == null || !isConnected())
return;
// Delete all pre-existing flows
log.info("Clearing all flows on switch {}", this);
OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.FLOW_MOD))
.setMatch(match)
.setCommand(OFFlowMod.OFPFC_DELETE)
.setOutPort(OFPort.OFPP_NONE)
.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
fm.setXid(getNextTransactionId());
OFMessage barrierMsg = floodlightProvider.getOFMessageFactory().getMessage(
OFType.BARRIER_REQUEST);
barrierMsg.setXid(getNextTransactionId());
List<OFMessage> msglist = new ArrayList<OFMessage>(2);
msglist.add(fm);
msglist.add(barrierMsg);
channel.write(msglist);
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:27,代码来源:OFSwitchBase.java
示例9: testMessageDispatchMaster
import org.openflow.protocol.OFType; //导入依赖的package包/类
/**
* Test dispatch of messages while in MASTER role
*/
@Test
public void testMessageDispatchMaster() throws Exception {
testInitialMoveToMasterWithRole();
// Send packet in. expect dispatch
OFPacketIn pi = (OFPacketIn)
BasicFactory.getInstance().getMessage(OFType.PACKET_IN);
reset(controller);
controller.handleMessage(sw, pi, null);
expectLastCall().once();
sendMessageToHandlerNoControllerReset(
Collections.<OFMessage>singletonList(pi));
verify(controller);
// TODO: many more to go
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:19,代码来源:OFChannelHandlerTest.java
示例10: OFMessageFuture
import org.openflow.protocol.OFType; //导入依赖的package包/类
public OFMessageFuture(IThreadPoolService tp,
IOFSwitch sw, OFType responseType, int transactionId, long timeout, TimeUnit unit) {
this.threadPool = tp;
this.canceled = false;
this.latch = new CountDownLatch(1);
this.responseType = responseType;
this.sw = sw;
this.transactionId = transactionId;
final OFMessageFuture<V> future = this;
timeoutTimer = new Runnable() {
@Override
public void run() {
if (timeoutTimer == this)
future.cancel(true);
}
};
threadPool.getScheduledExecutor().schedule(timeoutTimer, timeout, unit);
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:20,代码来源:OFMessageFuture.java
示例11: sendNxRoleRequest
import org.openflow.protocol.OFType; //导入依赖的package包/类
/**
* Send NX role request message to the switch requesting the specified
* role.
*
* @param sw switch to send the role request message to
* @param role role to request
*/
private int sendNxRoleRequest(Role role)
throws IOException {
int xid = sw.getNextTransactionId();
// Convert the role enum to the appropriate integer constant used
// in the NX role request message
int nxRole = role.toNxRole();
// Construct the role request message
OFVendor roleRequest = (OFVendor)BasicFactory.getInstance()
.getMessage(OFType.VENDOR);
roleRequest.setXid(xid);
roleRequest.setVendor(OFNiciraVendorData.NX_VENDOR_ID);
OFRoleRequestVendorData roleRequestData = new OFRoleRequestVendorData();
roleRequestData.setRole(nxRole);
roleRequest.setVendorData(roleRequestData);
roleRequest.setLengthU(OFVendor.MINIMUM_LENGTH +
roleRequestData.getLength());
// Send it to the switch
sw.write(Collections.<OFMessage>singletonList(roleRequest),
new FloodlightContext());
return xid;
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:33,代码来源:OFChannelHandler.java
示例12: testReassertMaster
import org.openflow.protocol.OFType; //导入依赖的package包/类
/**
* Test re-assert MASTER
*
*/
@Test
public void testReassertMaster() throws Exception {
testInitialMoveToMasterWithRole();
OFError err = (OFError)
BasicFactory.getInstance().getMessage(OFType.ERROR);
err.setXid(42);
err.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
err.setErrorCode(OFBadRequestCode.OFPBRC_EPERM);
reset(controller);
controller.reassertRole(handler, Role.MASTER);
expectLastCall().once();
controller.handleMessage(sw, err, null);
expectLastCall().once();
sendMessageToHandlerNoControllerReset(
Collections.<OFMessage>singletonList(err));
verify(sw);
verify(controller);
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:27,代码来源:OFChannelHandlerTest.java
示例13: setPacketIn
import org.openflow.protocol.OFType; //导入依赖的package包/类
protected void setPacketIn(IPacket packet) {
byte[] serializedPacket = packet.serialize();
// Build the PacketIn
this.packetIn = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(serializedPacket)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) serializedPacket.length);
// Add the packet to the context store
IFloodlightProviderService.bcStore.
put(cntx,
IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
(Ethernet)packet);
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:17,代码来源:FirewallTest.java
示例14: moveToWaitDescriptionStatReply
import org.openflow.protocol.OFType; //导入依赖的package包/类
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
* Builds on moveToWaitConfigReply()
* adds testing for WAIT_CONFIG_REPLY state
*/
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
moveToWaitConfigReply();
resetChannel();
channel.write(capture(writeCapture));
expectLastCall().andReturn(null).atLeastOnce();
replay(channel);
OFGetConfigReply cr = (OFGetConfigReply)BasicFactory.getInstance()
.getMessage(OFType.GET_CONFIG_REPLY);
cr.setMissSendLength((short)0xffff);
sendMessageToHandlerWithControllerReset(Collections.<OFMessage>singletonList(cr));
List<OFMessage> msgs = getMessagesFromCapture();
assertEquals(1, msgs.size());
assertEquals(OFType.STATS_REQUEST, msgs.get(0).getType());
OFStatisticsRequest sr = (OFStatisticsRequest)msgs.get(0);
assertEquals(OFStatisticsType.DESC, sr.getStatisticType());
// no idea why an OFStatisticsRequest even /has/ a getStatistics()
// methods. It really shouldn't
assertNull(sr.getStatistics());
verifyUniqueXids(msgs);
assertEquals(OFChannelHandler.ChannelState.WAIT_DESCRIPTION_STAT_REPLY,
handler.getStateForTesting());
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:31,代码来源:OFChannelHandlerTest.java
示例15: isCallbackOrderingPrereq
import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
/*
* ????????ģ?????˳??
*/
public boolean isCallbackOrderingPrereq(OFType type, String name) {
// TODO Auto-generated method stub
return (name.equals("linkdiscovery"));
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:9,代码来源:FlowDispatcher.java
示例16: setEnabled
import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void setEnabled(boolean enabled) {
if(enabled){
bootstrap(floodlightProvider.getListeners().get(OFType.PACKET_IN));
}
this.isEnabled = enabled;
logger.debug("Setting module to " + isEnabled);
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:9,代码来源:PktInProcessingTime.java
示例17: doDropFlow
import org.openflow.protocol.OFType; //导入依赖的package包/类
@LogMessageDoc(level="ERROR",
message="Failure writing drop flow mod",
explanation="An I/O error occured while trying to write a " +
"drop flow mod to a switch",
recommendation=LogMessageDoc.CHECK_SWITCH)
protected void doDropFlow(IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision, FloodlightContext cntx) {
// initialize match structure and populate it using the packet
OFMatch match = new OFMatch();
match.loadFromPacket(pi.getPacketData(), pi.getInPort());
if (decision.getWildcards() != null) {
match.setWildcards(decision.getWildcards());
}
// Create flow-mod based on packet-in and src-switch
OFFlowMod fm =
(OFFlowMod) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.FLOW_MOD);
List<OFAction> actions = new ArrayList<OFAction>(); // Set no action to
// drop
long cookie = AppCookie.makeCookie(FORWARDING_APP_ID, 0);
fm.setCookie(cookie)
.setHardTimeout((short) 0)
.setIdleTimeout((short) 5)
.setBufferId(OFPacketOut.BUFFER_ID_NONE)
.setMatch(match)
.setActions(actions)
.setLengthU(OFFlowMod.MINIMUM_LENGTH); // +OFActionOutput.MINIMUM_LENGTH);
try {
if (log.isDebugEnabled()) {
log.debug("write drop flow-mod sw={} match={} flow-mod={}",
new Object[] { sw, match, fm });
}
messageDamper.write(sw, fm, cntx);
} catch (IOException e) {
log.error("Failure writing drop flow mod", e);
}
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:40,代码来源:Forwarding.java
示例18: getRoleReply
import org.openflow.protocol.OFType; //导入依赖的package包/类
/** Return a Nicira RoleReply message for the given role */
private OFMessage getRoleReply(int xid, Role role) {
OFVendor vm = (OFVendor)BasicFactory.getInstance()
.getMessage(OFType.VENDOR);
vm.setXid(xid);
vm.setVendor(OFNiciraVendorData.NX_VENDOR_ID);
OFRoleReplyVendorData replyData = new OFRoleReplyVendorData();
replyData.setRole(role.toNxRole());
vm.setVendorData(replyData);
return vm;
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:12,代码来源:OFChannelHandlerTest.java
示例19: startUp
import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void startUp(FloodlightModuleContext context) {
// initialize REST interface
restApi.addRestletRoutable(new QoSWebRoutable());
floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
//Storage for policies
storageSource.createTable(TABLE_NAME, null);
storageSource.setTablePrimaryKeyName(TABLE_NAME, COLUMN_POLID);
//avoid thread issues for concurrency
synchronized (policies) {
this.policies = readPoliciesFromStorage();
}
//Storage for services
storageSource.createTable(TOS_TABLE_NAME, null);
storageSource.setTablePrimaryKeyName(TOS_TABLE_NAME, COLUMN_SID);
//avoid thread issues for concurrency
synchronized (services) {
this.services = readServicesFromStorage();
}
// create default "Best Effort" service
// most networks use this as default, adding here for defaulting
try{
QoSTypeOfService service = new QoSTypeOfService();
service.name = "Best Effort";
service.tos = (byte)0x00;
service.sid = service.genID();
this.addService(service);
}catch(Exception e){
logger.error("Error adding default Best Effort {}", e);
}
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:35,代码来源:QoS.java
示例20: doDropFlow
import org.openflow.protocol.OFType; //导入依赖的package包/类
/**
* Writes a FlowMod to a switch that inserts a drop flow.
* @param sw The switch to write the FlowMod to.
* @param pi The corresponding OFPacketIn. Used to create the OFMatch structure.
* @param cntx The FloodlightContext that gets passed to the switch.
*/
protected void doDropFlow(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
if (log.isTraceEnabled()) {
log.trace("doDropFlow pi={} srcSwitch={}",
new Object[] { pi, sw });
}
if (sw == null) {
log.warn("Switch is null, not installing drop flowmod for PacketIn {}", pi);
return;
}
// Create flow-mod based on packet-in and src-switch
OFFlowMod fm =
(OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
OFMatch match = new OFMatch();
match.loadFromPacket(pi.getPacketData(), pi.getInPort());
List<OFAction> actions = new ArrayList<OFAction>(); // no actions = drop
long cookie = AppCookie.makeCookie(APP_ID, 0);
fm.setCookie(cookie)
.setIdleTimeout(ForwardingBase.FLOWMOD_DEFAULT_IDLE_TIMEOUT)
.setHardTimeout(ForwardingBase.FLOWMOD_DEFAULT_HARD_TIMEOUT)
.setBufferId(OFPacketOut.BUFFER_ID_NONE)
.setMatch(match)
.setActions(actions)
.setLengthU(OFFlowMod.MINIMUM_LENGTH);
// fm.setFlags(OFFlowMod.OFPFF_SEND_FLOW_REM);
try {
if (log.isTraceEnabled()) {
log.trace("write drop flow-mod srcSwitch={} match={} " +
"pi={} flow-mod={}",
new Object[] {sw, match, pi, fm});
}
sw.write(fm, cntx);
} catch (IOException e) {
log.error("Failure writing drop flow mod", e);
}
return;
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:45,代码来源:VirtualNetworkFilter.java
注:本文中的org.openflow.protocol.OFType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论