• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MastershipService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.onosproject.mastership.MastershipService的典型用法代码示例。如果您正苦于以下问题:Java MastershipService类的具体用法?Java MastershipService怎么用?Java MastershipService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MastershipService类属于org.onosproject.mastership包,在下文中一共展示了MastershipService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: execute

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
@Override
protected void execute() {
    ClusterService service = get(ClusterService.class);
    MastershipService mastershipService = get(MastershipService.class);
    List<ControllerNode> nodes = newArrayList(service.getNodes());
    Collections.sort(nodes, Comparators.NODE_COMPARATOR);

    if (outputJson()) {
        print("%s", json(service, mastershipService, nodes));
    } else {
        for (ControllerNode node : nodes) {
            List<DeviceId> ids = Lists.newArrayList(mastershipService.getDevicesOf(node.id()));
            Collections.sort(ids, Comparators.ELEMENT_ID_COMPARATOR);
            print("%s: %d devices", node.id(), ids.size());
            for (DeviceId deviceId : ids) {
                print("  %s", deviceId);
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:MastersListCommand.java


示例2: populateRow

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
private void populateRow(TableModel.Row row, Device dev,
                         DeviceService ds, MastershipService ms) {
    DeviceId id = dev.id();
    boolean available = ds.isAvailable(id);
    String iconId = available ? ICON_ID_ONLINE : ICON_ID_OFFLINE;

    row.cell(ID, id)
        .cell(NAME, deviceName(dev))
        .cell(AVAILABLE, available)
        .cell(AVAILABLE_IID, iconId)
        .cell(TYPE_IID, getTypeIconId(dev))
        .cell(MFR, dev.manufacturer())
        .cell(HW, dev.hwVersion())
        .cell(SW, dev.swVersion())
        .cell(PROTOCOL, deviceProtocol(dev))
        .cell(NUM_PORTS, ds.getPorts(id).size())
        .cell(MASTER_ID, ms.getMasterFor(id));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:DeviceViewMessageHandler.java


示例3: init

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
@Override
public void init(UiConnection connection, ServiceDirectory directory) {
    super.init(connection, directory);
    this.directory = checkNotNull(directory, "Directory cannot be null");
    clusterService = directory.get(ClusterService.class);
    deviceService = directory.get(DeviceService.class);
    linkService = directory.get(LinkService.class);
    hostService = directory.get(HostService.class);
    mastershipService = directory.get(MastershipService.class);
    intentService = directory.get(IntentService.class);
    flowService = directory.get(FlowRuleService.class);
    flowStatsService = directory.get(StatisticService.class);
    portStatsService = directory.get(PortStatisticsService.class);
    topologyService = directory.get(TopologyService.class);
    tunnelService = directory.get(TunnelService.class);

    servicesBundle = new ServicesBundle(intentService, deviceService,
                                        hostService, linkService,
                                        flowService,
                                        flowStatsService, portStatsService);

    String ver = directory.get(CoreService.class).version().toString();
    version = ver.replace(".SNAPSHOT", "*").replaceFirst("~.*$", "");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:TopologyViewMessageHandlerBase.java


示例4: getControllers

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
@Override
public List<ControllerInfo> getControllers() {
    DriverHandler handler = handler();
    NetconfController controller = handler.get(NetconfController.class);
    MastershipService mastershipService = handler.get(MastershipService.class);
    DeviceId deviceId = handler.data().deviceId();
    Preconditions.checkNotNull(controller, "Netconf controller is null");
    List<ControllerInfo> controllers = new ArrayList<>();
    if (mastershipService.isLocalMaster(deviceId)) {
        try {
            String reply = controller.getNetconfDevice(deviceId).getSession().
                    getConfig("running");
            log.debug("Reply XML {}", reply);
            controllers.addAll(XmlConfigParser.parseStreamControllers(XmlConfigParser.
                    loadXml(new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8)))));
        } catch (IOException e) {
            log.error("Cannot communicate with device {} ", deviceId, e);
        }
    } else {
        log.warn("I'm not master for {} please use master, {} to execute command",
                 deviceId,
                 mastershipService.getMasterFor(deviceId));
    }
    return controllers;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:NetconfControllerConfig.java


示例5: init

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
/**
 * Initializes a new topology simulator with access to the specified service
 * directory and various provider services.
 *
 * @param topoShape             topology shape specifier
 * @param deviceCount           number of devices in the topology
 * @param hostCount             number of hosts per device
 * @param directory             service directory
 * @param deviceProviderService device provider service
 * @param hostProviderService   host provider service
 * @param linkProviderService   link provider service
 */
protected void init(String topoShape, int deviceCount, int hostCount,
                    ServiceDirectory directory,
                    DeviceProviderService deviceProviderService,
                    HostProviderService hostProviderService,
                    LinkProviderService linkProviderService) {
    this.deviceCount = deviceCount;
    this.hostCount = hostCount;
    this.directory = directory;

    this.clusterService = directory.get(ClusterService.class);
    this.mastershipService = directory.get(MastershipService.class);

    this.deviceService = directory.get(DeviceAdminService.class);
    this.hostService = directory.get(HostService.class);
    this.linkService = directory.get(LinkService.class);
    this.deviceProviderService = deviceProviderService;
    this.hostProviderService = hostProviderService;
    this.linkProviderService = linkProviderService;

    localNode = clusterService.getLocalNode().id();

    processTopoShape(topoShape);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:TopologySimulator.java


示例6: init

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
/**
 * Initializes the provider with necessary supporting services.
 *
 * @param providerService   flow rule provider service
 * @param deviceService     device service
 * @param mastershipService mastership service
 * @param pollFrequency     flow entry poll frequency
 */
void init(FlowRuleProviderService providerService,
          DeviceService deviceService, MastershipService mastershipService,
          int pollFrequency) {
    this.providerService = providerService;
    this.deviceService = deviceService;
    this.mastershipService = mastershipService;

    deviceService.addListener(deviceListener);

    if (poller != null && !poller.isCancelled()) {
        poller.cancel(false);
    }

    poller = executor.scheduleAtFixedRate(this::pollFlowEntries, pollFrequency,
                                          pollFrequency, TimeUnit.SECONDS);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:FlowRuleDriverProvider.java


示例7: TopologyViewMessages

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
/**
 * Creates a messaging facility for creating messages for topology viewer.
 *
 * @param directory service directory
 */
protected TopologyViewMessages(ServiceDirectory directory) {
    this.directory = checkNotNull(directory, "Directory cannot be null");
    clusterService = directory.get(ClusterService.class);
    deviceService = directory.get(DeviceService.class);
    linkService = directory.get(LinkService.class);
    hostService = directory.get(HostService.class);
    mastershipService = directory.get(MastershipService.class);
    intentService = directory.get(IntentService.class);
    flowService = directory.get(FlowRuleService.class);
    statService = directory.get(StatisticService.class);
    topologyService = directory.get(TopologyService.class);

    String ver = directory.get(CoreService.class).version().toString();
    version = ver.replace(".SNAPSHOT", "*").replaceFirst("~.*$", "");
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:21,代码来源:TopologyViewMessages.java


示例8: process

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
@Override
public void process(ObjectNode message) {
    ObjectNode payload = payload(message);
    String sortCol = string(payload, "sortCol", "id");
    String sortDir = string(payload, "sortDir", "asc");

    DeviceService service = get(DeviceService.class);
    MastershipService mastershipService = get(MastershipService.class);
    LinkService linkService = get(LinkService.class);
    TableRow[] rows = generateTableRows(service,
                                        mastershipService,
                                        linkService);
    RowComparator rc =
            new RowComparator(sortCol, RowComparator.direction(sortDir));
    Arrays.sort(rows, rc);
    ArrayNode devices = generateArrayNode(rows);
    ObjectNode rootNode = mapper.createObjectNode();
    rootNode.set("devices", devices);

    connection().sendMessage("deviceDataResponse", 0, rootNode);
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:22,代码来源:DeviceViewMessageHandler.java


示例9: init

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
@Override
public void init(UiConnection connection, ServiceDirectory directory) {
    super.init(connection, directory);
    this.directory = checkNotNull(directory, "Directory cannot be null");
    clusterService = directory.get(ClusterService.class);
    deviceService = directory.get(DeviceService.class);
    linkService = directory.get(LinkService.class);
    hostService = directory.get(HostService.class);
    mastershipService = directory.get(MastershipService.class);
    intentService = directory.get(IntentService.class);
    flowService = directory.get(FlowRuleService.class);
    statService = directory.get(StatisticService.class);
    topologyService = directory.get(TopologyService.class);

    String ver = directory.get(CoreService.class).version().toString();
    version = ver.replace(".SNAPSHOT", "*").replaceFirst("~.*$", "");
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:18,代码来源:TopologyViewMessageHandlerBase.java


示例10: ServicesBundle

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
/**
 * Creates the services bundle, from the given directly.
 *
 * @param directory service directory
 */
public ServicesBundle(ServiceDirectory directory) {
    checkNotNull(directory, "Directory cannot be null");

    clusterService = directory.get(ClusterService.class);

    topologyService = directory.get(TopologyService.class);
    deviceService = directory.get(DeviceService.class);
    hostService = directory.get(HostService.class);
    linkService = directory.get(LinkService.class);
    tunnelService = directory.get(TunnelService.class);

    mastershipService = directory.get(MastershipService.class);
    mastershipAdminService = directory.get(MastershipAdminService.class);
    intentService = directory.get(IntentService.class);
    flowService = directory.get(FlowRuleService.class);
    flowStatsService = directory.get(StatisticService.class);
    portStatsService = directory.get(PortStatisticsService.class);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:ServicesBundle.java


示例11: Topo2Jsonifier

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
/**
 * Creates an instance with a reference to the services directory, so that
 * additional information about network elements may be looked up on
 * on the fly.
 *
 * @param directory service directory
 * @param userName  logged in user name
 */
public Topo2Jsonifier(ServiceDirectory directory, String userName) {
    this.directory = checkNotNull(directory, "Directory cannot be null");
    this.userName = checkNotNull(userName, "User name cannot be null");

    clusterService = directory.get(ClusterService.class);
    deviceService = directory.get(DeviceService.class);
    linkService = directory.get(LinkService.class);
    hostService = directory.get(HostService.class);
    mastershipService = directory.get(MastershipService.class);
    intentService = directory.get(IntentService.class);
    flowService = directory.get(FlowRuleService.class);
    flowStatsService = directory.get(StatisticService.class);
    portStatsService = directory.get(PortStatisticsService.class);
    topologyService = directory.get(TopologyService.class);
    tunnelService = directory.get(TunnelService.class);
    uiextService = directory.get(UiExtensionService.class);
    prefService = directory.get(UiPreferencesService.class);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:27,代码来源:Topo2Jsonifier.java


示例12: getControllers

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
@Override
public List<ControllerInfo> getControllers() {
    DriverHandler handler = handler();
    NetconfController controller = handler.get(NetconfController.class);
    MastershipService mastershipService = handler.get(MastershipService.class);
    DeviceId deviceId = handler.data().deviceId();
    Preconditions.checkNotNull(controller, "Netconf controller is null");
    List<ControllerInfo> controllers = new ArrayList<>();
    if (mastershipService.isLocalMaster(deviceId)) {
        try {
            String reply = controller.getNetconfDevice(deviceId).getSession().
                    getConfig(DatastoreId.RUNNING);
            log.debug("Reply XML {}", reply);
            controllers.addAll(XmlConfigParser.parseStreamControllers(XmlConfigParser.
                    loadXml(new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8)))));
        } catch (NetconfException e) {
            log.error("Cannot communicate with device {} ", deviceId, e);
        }
    } else {
        log.warn("I'm not master for {} please use master, {} to execute command",
                 deviceId,
                 mastershipService.getMasterFor(deviceId));
    }
    return controllers;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:26,代码来源:NetconfControllerConfig.java


示例13: setControllers

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
@Override
public void setControllers(List<ControllerInfo> controllers) {
    DriverHandler handler = handler();
    NetconfController controller = handler.get(NetconfController.class);
    MastershipService mastershipService = handler.get(MastershipService.class);
    DeviceId ncdeviceId = handler.data().deviceId();
    checkNotNull(controller, "Netconf controller is null");
    if (mastershipService.isLocalMaster(ncdeviceId)) {
        try {
            NetconfDevice device = controller.getNetconfDevice(ncdeviceId);
            String config = createVoltControllersConfig(
                    XmlConfigParser.loadXml(getClass().
                            getResourceAsStream(RESOURCE_XML)),
                    RUNNING, MERGE, controllers);
            device.getSession().editConfig(config.substring(
                    config.indexOf(END_LICENSE_HEADER) + END_LICENSE_HEADER.length()));
        } catch (NetconfException e) {
            log.error("Cannot communicate to device {} , exception {}", ncdeviceId, e);
        }
    } else {
        log.warn("I'm not master for {} please use master, {} to execute command",
                 ncdeviceId,
                 mastershipService.getMasterFor(ncdeviceId));
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:26,代码来源:FujitsuVoltControllerConfig.java


示例14: getTableStatistics

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
@Override
public Iterable<TableStatisticsEntry> getTableStatistics(NetworkId networkId, DeviceId deviceId) {
    MastershipService mastershipService =
            vnaService.get(networkId, MastershipService.class);
    NodeId master = mastershipService.getMasterFor(deviceId);

    if (master == null) {
        log.debug("Failed to getTableStats: No master for {}", deviceId);
        return Collections.emptyList();
    }

    if (deviceTableStats.get(networkId) == null) {
        deviceTableStats.put(networkId, Maps.newConcurrentMap());
    }

    List<TableStatisticsEntry> tableStats = deviceTableStats.get(networkId).get(deviceId);
    if (tableStats == null) {
        return Collections.emptyList();
    }
    return ImmutableList.copyOf(tableStats);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:22,代码来源:DistributedVirtualFlowRuleStore.java


示例15: execute

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
@Override
protected void execute() {
    ClusterService service = get(ClusterService.class);
    MastershipService mastershipService = get(MastershipService.class);
    DeviceService deviceService = get(DeviceService.class);
    List<ControllerNode> nodes = newArrayList(service.getNodes());
    Collections.sort(nodes, Comparators.NODE_COMPARATOR);

    if (outputJson()) {
        print("%s", json(service, mastershipService, nodes));
    } else {
        for (ControllerNode node : nodes) {
            List<DeviceId> ids = Lists.newArrayList(mastershipService.getDevicesOf(node.id()));
            ids.removeIf(did -> deviceService.getDevice(did) == null);
            Collections.sort(ids, Comparators.ELEMENT_ID_COMPARATOR);
            print("%s: %d devices", node.id(), ids.size());
            for (DeviceId deviceId : ids) {
                print("  %s", deviceId);
            }
        }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:MastersListCommand.java


示例16: init

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
/**
 * Initializes the provider with the necessary device service, group provider service,
 * mastership service and poll frequency.
 *
 * @param deviceService        device service
 * @param groupProviderService group provider service
 * @param mastershipService    mastership service
 * @param pollFrequency        group entry poll frequency
 */
void init(DeviceService deviceService, GroupProviderService groupProviderService,
          MastershipService mastershipService, int pollFrequency) {
    this.deviceService = deviceService;
    this.groupProviderService = groupProviderService;
    this.mastershipService = mastershipService;

    deviceService.addListener(deviceListener);

    if (poller != null && !poller.isCancelled()) {
        poller.cancel(false);
    }

    poller = executor.scheduleAtFixedRate(this::pollGroups, pollFrequency,
            pollFrequency, TimeUnit.SECONDS);

}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:26,代码来源:GroupDriverProvider.java


示例17: init

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
/**
 * Initializes the provider with the necessary device service, meter provider service,
 * mastership service and poll frequency.
 *
 * @param deviceService        device service
 * @param meterProviderService meter provider service
 * @param mastershipService    mastership service
 * @param pollFrequency        meter entry poll frequency
 */
void init(DeviceService deviceService, MeterProviderService meterProviderService,
          MastershipService mastershipService, int pollFrequency) {
    this.deviceService = deviceService;
    this.meterProviderService = meterProviderService;
    this.mastershipService = mastershipService;
    this.pollFrequency = pollFrequency;

    deviceService.addListener(deviceListener);

    if (poller != null && !poller.isCancelled()) {
        poller.cancel(false);
    }

    poller = executor.scheduleAtFixedRate(this::pollMeters, pollFrequency,
            pollFrequency, TimeUnit.SECONDS);

}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:27,代码来源:MeterDriverProvider.java


示例18: setUpTest

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
/**
 * Sets up the global values for all the tests.
 */
@Before
public void setUpTest() {

    final CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory =
            new TestServiceDirectory()
                    .add(MastershipService.class, mockService)
                    .add(MastershipAdminService.class, mockAdminService)
                    .add(CodecService.class, codecService);

    BaseResource.setServiceDirectory(testDirectory);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:MastershipResourceTest.java


示例19: populateTable

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
@Override
protected void populateTable(TableModel tm, ObjectNode payload) {
    DeviceService ds = get(DeviceService.class);
    MastershipService ms = get(MastershipService.class);
    for (Device dev : ds.getDevices()) {
        populateRow(tm.addRow(), dev, ds, ms);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:DeviceViewMessageHandler.java


示例20: process

import org.onosproject.mastership.MastershipService; //导入依赖的package包/类
@Override
public void process(long sid, ObjectNode payload) {
    String id = string(payload, ID, ZERO_URI);

    DeviceId deviceId = deviceId(id);
    DeviceService service = get(DeviceService.class);
    MastershipService ms = get(MastershipService.class);
    Device device = service.getDevice(deviceId);
    ObjectNode data = objectNode();
    NodeId masterFor = ms.getMasterFor(deviceId);

    data.put(ID, deviceId.toString());
    data.put(NAME, deviceName(device));
    data.put(TYPE, capitalizeFully(device.type().toString()));
    data.put(TYPE_IID, getTypeIconId(device));
    data.put(MFR, device.manufacturer());
    data.put(HW, device.hwVersion());
    data.put(SW, device.swVersion());
    data.put(SERIAL, device.serialNumber());
    data.put(CHASSIS_ID, device.chassisId().toString());
    data.put(MASTER_ID, masterFor != null ? masterFor.toString() : NONE);
    data.put(PROTOCOL, deviceProtocol(device));

    ArrayNode ports = arrayNode();

    List<Port> portList = new ArrayList<>(service.getPorts(deviceId));
    Collections.sort(portList, (p1, p2) -> {
        long delta = p1.number().toLong() - p2.number().toLong();
        return delta == 0 ? 0 : (delta < 0 ? -1 : +1);
    });

    for (Port p : portList) {
        ports.add(portData(p, deviceId));
    }
    data.set(PORTS, ports);

    ObjectNode rootNode = objectNode();
    rootNode.set(DETAILS, data);
    sendMessage(DEV_DETAILS_RESP, 0, rootNode);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:41,代码来源:DeviceViewMessageHandler.java



注:本文中的org.onosproject.mastership.MastershipService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Expressions类代码示例发布时间:2022-05-22
下一篇:
Java ManagementService类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap