当前位置: 首页>>代码示例>>Java>>正文


Java MastershipService类代码示例

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


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


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