本文整理汇总了Java中org.opendaylight.controller.switchmanager.SpanConfig类的典型用法代码示例。如果您正苦于以下问题:Java SpanConfig类的具体用法?Java SpanConfig怎么用?Java SpanConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpanConfig类属于org.opendaylight.controller.switchmanager包,在下文中一共展示了SpanConfig类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveSwitchConfigInternal
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
public Status saveSwitchConfigInternal() {
Status retS = null, retP = null;
ObjectWriter objWriter = new ObjectWriter();
retS = objWriter.write(new ConcurrentHashMap<String, SubnetConfig>(
subnetsConfigList), subnetFileName);
retP = objWriter.write(new ConcurrentHashMap<SpanConfig, SpanConfig>(
spanConfigList), spanFileName);
retS = objWriter.write(new ConcurrentHashMap<String, SwitchConfig>(
nodeConfigList), switchConfigFileName);
if (retS.equals(retP)) {
if (retS.isSuccess()) {
return retS;
} else {
return new Status(StatusCode.INTERNALERROR, "Save failed");
}
} else {
return new Status(StatusCode.INTERNALERROR, "Partial save failure");
}
}
示例2: addSpanConfig
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
@Override
public Status addSpanConfig(SpanConfig conf) {
// Valid config check
if (!conf.isValidConfig()) {
String msg = "Invalid Span configuration";
log.warn(msg);
return new Status(StatusCode.BADREQUEST, msg);
}
// Presence check
if (spanConfigList.containsKey(conf)) {
return new Status(StatusCode.CONFLICT, "Same span config exists");
}
// Update configuration
if (spanConfigList.putIfAbsent(conf, conf) == null) {
// Update database and notify clients
addSpanPorts(conf.getNode(), conf.getPortArrayList());
}
return new Status(StatusCode.SUCCESS);
}
示例3: addSpanPort
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
@RequestMapping(value = "/spanPorts/add", method = RequestMethod.GET)
@ResponseBody
public StatusJsonBean addSpanPort(
@RequestParam("jsonData") String jsonData,
HttpServletRequest request,
@RequestParam(required = false) String container) {
String containerName = (container == null) ? GlobalConstants.DEFAULT
.toString() : container;
// Authorization check
String userName = request.getUserPrincipal().getName();
if (DaylightWebUtil.getContainerPrivilege(userName, containerName, this) != Privilege.WRITE) {
return unauthorizedMessage();
}
StatusJsonBean resultBean = new StatusJsonBean();
try {
Gson gson = new Gson();
ISwitchManager switchManager = (ISwitchManager) ServiceHelper
.getInstance(ISwitchManager.class, containerName, this);
SpanConfig cfgObject = gson.fromJson(jsonData, SpanConfig.class);
Status result = switchManager.addSpanConfig(cfgObject);
if (result.isSuccess()) {
resultBean.setStatus(true);
resultBean.setMessage("SPAN Port added successfully");
} else {
resultBean.setStatus(false);
resultBean.setMessage(result.getDescription());
}
} catch (Exception e) {
resultBean.setStatus(false);
resultBean.setMessage("Error occurred while adding span port. "
+ e.getMessage());
}
return resultBean;
}
示例4: nonClusterObjectCreate
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
private void nonClusterObjectCreate() {
subnetsConfigList = new ConcurrentHashMap<String, SubnetConfig>();
spanConfigList = new ConcurrentHashMap<SpanConfig, SpanConfig>();
nodeConfigList = new ConcurrentHashMap<String, SwitchConfig>();
subnets = new ConcurrentHashMap<InetAddress, Subnet>();
configSaveEvent = new ConcurrentHashMap<Long, String>();
nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
nodeConnectorProps = new ConcurrentHashMap<NodeConnector, Map<String, Property>>();
nodeConnectorNames = new ConcurrentHashMap<Node, Map<String, NodeConnector>>();
}
示例5: getSpanConfigList
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
private List<SpanConfig> getSpanConfigList(Node node) {
List<SpanConfig> confList = new ArrayList<SpanConfig>();
String nodeId = node.toString();
for (SpanConfig conf : spanConfigList.values()) {
if (conf.matchNode(nodeId)) {
confList.add(conf);
}
}
return confList;
}
示例6: loadSpanConfiguration
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void loadSpanConfiguration() {
ObjectReader objReader = new ObjectReader();
ConcurrentMap<Integer, SpanConfig> confList = (ConcurrentMap<Integer, SpanConfig>) objReader
.read(this, spanFileName);
if (confList == null) {
return;
}
for (SpanConfig conf : confList.values()) {
addSpanConfig(conf);
}
}
示例7: removeSpanConfig
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
@Override
public Status removeSpanConfig(SpanConfig conf) {
removeSpanPorts(conf.getNode(), conf.getPortArrayList());
// Update configuration
spanConfigList.remove(conf);
return new Status(StatusCode.SUCCESS);
}
示例8: spanAwareNotify
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
private void spanAwareNotify(ISpanAware service) {
for (Node node : getNodes()) {
for (SpanConfig conf : getSpanConfigList(node)) {
service.spanUpdate(node, conf.getPortArrayList(), true);
}
}
}
示例9: addSpanPort
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
private void addSpanPort(NodeConnector nodeConnector) {
// only add if span is configured on this nodeConnector
for (SpanConfig conf : getSpanConfigList(nodeConnector.getNode())) {
if (conf.getPortArrayList().contains(nodeConnector)) {
List<NodeConnector> ncLists = new ArrayList<NodeConnector>();
ncLists.add(nodeConnector);
addSpanPorts(nodeConnector.getNode(), ncLists);
return;
}
}
}
示例10: getSpanPorts
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
@RequestMapping(value = "/spanPorts", method = RequestMethod.GET)
@ResponseBody
public DevicesJsonBean getSpanPorts(HttpServletRequest request,
@RequestParam(required = false) String container) {
Gson gson = new Gson();
List<Map<String, String>> spanConfigs = new ArrayList<Map<String, String>>();
String containerName = (container == null) ? GlobalConstants.DEFAULT
.toString() : container;
// Derive the privilege this user has on the current container
String userName = request.getUserPrincipal().getName();
Privilege privilege = DaylightWebUtil.getContainerPrivilege(
userName, containerName, this);
if (privilege != Privilege.NONE) {
List<String> spanConfigs_json = new ArrayList<String>();
ISwitchManager switchManager = (ISwitchManager) ServiceHelper
.getInstance(ISwitchManager.class, containerName, this);
if (switchManager != null) {
for (SpanConfig conf : switchManager.getSpanConfigList()) {
spanConfigs_json.add(gson.toJson(conf));
}
}
ObjectMapper mapper = new ObjectMapper();
for (String config_json : spanConfigs_json) {
try {
@SuppressWarnings("unchecked")
Map<String, String> config_data = mapper.readValue(config_json,
HashMap.class);
Map<String, String> config = new HashMap<String, String>();
for (String name : config_data.keySet()) {
config.put(name, config_data.get(name));
// Add switch name value (non-configuration field)
config.put("nodeName",
getNodeDesc(config_data.get("nodeId"), containerName));
}
config.put("json", config_json);
spanConfigs.add(config);
} catch (Exception e) {
// TODO: Handle the exception.
}
}
}
DevicesJsonBean result = new DevicesJsonBean();
result.setPrivilege(privilege);
result.setColumnNames(SpanConfig.getGuiFieldsNames());
result.setNodeData(spanConfigs);
return result;
}
示例11: deleteSpanPorts
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
@RequestMapping(value = "/spanPorts/delete", method = RequestMethod.GET)
@ResponseBody
public StatusJsonBean deleteSpanPorts(
@RequestParam("spanPortsToDelete") String spanPortsToDelete,
HttpServletRequest request,
@RequestParam(required = false) String container) {
String containerName = (container == null) ? GlobalConstants.DEFAULT
.toString() : container;
// Authorization check
String userName = request.getUserPrincipal().getName();
if (DaylightWebUtil.getContainerPrivilege(userName, containerName, this) != Privilege.WRITE) {
return unauthorizedMessage();
}
StatusJsonBean resultBean = new StatusJsonBean();
try {
Gson gson = new Gson();
ISwitchManager switchManager = (ISwitchManager) ServiceHelper
.getInstance(ISwitchManager.class, containerName, this);
String[] spans = spanPortsToDelete.split("###");
resultBean.setStatus(true);
resultBean.setMessage("SPAN Port(s) deleted successfully");
for (String span : spans) {
if (!span.isEmpty()) {
SpanConfig cfgObject = gson
.fromJson(span, SpanConfig.class);
Status result = switchManager.removeSpanConfig(cfgObject);
if (!result.isSuccess()) {
resultBean.setStatus(false);
resultBean.setMessage(result.getDescription());
break;
}
}
}
} catch (Exception e) {
resultBean.setStatus(false);
resultBean.setMessage("Error occurred while deleting span port. "
+ e.getMessage());
}
return resultBean;
}
示例12: retrieveCaches
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "deprecation" })
private void retrieveCaches() {
if (this.clusterContainerService == null) {
log.info("un-initialized clusterContainerService, can't create cache");
return;
}
subnetsConfigList = (ConcurrentMap<String, SubnetConfig>) clusterContainerService
.getCache("switchmanager.subnetsConfigList");
if (subnetsConfigList == null) {
log.error("\nFailed to get cache for subnetsConfigList");
}
spanConfigList = (ConcurrentMap<SpanConfig, SpanConfig>) clusterContainerService
.getCache("switchmanager.spanConfigList");
if (spanConfigList == null) {
log.error("\nFailed to get cache for spanConfigList");
}
nodeConfigList = (ConcurrentMap<String, SwitchConfig>) clusterContainerService
.getCache("switchmanager.nodeConfigList");
if (nodeConfigList == null) {
log.error("\nFailed to get cache for nodeConfigList");
}
subnets = (ConcurrentMap<InetAddress, Subnet>) clusterContainerService
.getCache("switchmanager.subnets");
if (subnets == null) {
log.error("\nFailed to get cache for subnets");
}
configSaveEvent = (ConcurrentMap<Long, String>) clusterContainerService
.getCache("switchmanager.configSaveEvent");
if (configSaveEvent == null) {
log.error("\nFailed to get cache for configSaveEvent");
}
nodeProps = (ConcurrentMap<Node, Map<String, Property>>) clusterContainerService
.getCache("switchmanager.nodeProps");
if (nodeProps == null) {
log.error("\nFailed to get cache for nodeProps");
}
nodeConnectorProps = (ConcurrentMap<NodeConnector, Map<String, Property>>) clusterContainerService
.getCache("switchmanager.nodeConnectorProps");
if (nodeConnectorProps == null) {
log.error("\nFailed to get cache for nodeConnectorProps");
}
nodeConnectorNames = (ConcurrentMap<Node, Map<String, NodeConnector>>) clusterContainerService
.getCache("switchmanager.nodeConnectorNames");
if (nodeConnectorNames == null) {
log.error("\nFailed to get cache for nodeConnectorNames");
}
}
示例13: addSpanPorts
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
private void addSpanPorts(Node node) {
for (SpanConfig conf : getSpanConfigList(node)) {
addSpanPorts(node, conf.getPortArrayList());
}
}
示例14: removeSpanPorts
import org.opendaylight.controller.switchmanager.SpanConfig; //导入依赖的package包/类
private void removeSpanPorts(Node node) {
for (SpanConfig conf : getSpanConfigList(node)) {
addSpanPorts(node, conf.getPortArrayList());
}
}