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

Java Tools类代码示例

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

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



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

示例1: activate

import org.onlab.util.Tools; //导入依赖的package包/类
@Activate
protected void activate() {
    cache = new ModelCache(new DefaultServiceBundle(), eventDispatcher);
    eventHandler = Executors.newSingleThreadExecutor(Tools.groupedThreads("onos/ui/topo", "event-handler"));

    eventDispatcher.addSink(UiModelEvent.class, listenerRegistry);

    clusterService.addListener(clusterListener);
    mastershipService.addListener(mastershipListener);
    regionService.addListener(regionListener);
    deviceService.addListener(deviceListener);
    linkService.addListener(linkListener);
    hostService.addListener(hostListener);
    intentService.addListener(intentListener);
    flowService.addListener(flowRuleListener);

    cache.load();

    log.info("Started");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:UiSharedTopologyModel.java


示例2: displayLeaders

import org.onlab.util.Tools; //导入依赖的package包/类
/**
 * Displays text representing the leaders.
 *
 * @param leaderBoard map of leaders
 */
private void displayLeaders(Map<String, Leadership> leaderBoard) {
    print("------------------------------------------------------------------------");
    print(FMT, "Topic", "Leader", "Term", "Elected");
    print("------------------------------------------------------------------------");

    leaderBoard.values()
            .stream()
            .filter(l -> allTopics || pattern.matcher(l.topic()).matches())
            .filter(l -> l.leader() != null)
            .sorted(leadershipComparator)
            .forEach(l -> print(FMT,
                    l.topic(),
                    l.leaderNodeId(),
                    l.leader().term(),
                    Tools.timeAgo(l.leader().termStartTime())));
    print("------------------------------------------------------------------------");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:LeaderCommand.java


示例3: execute

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
protected void execute() {
    ClusterAdminService service = get(ClusterAdminService.class);
    List<ControllerNode> nodes = newArrayList(service.getNodes());
    Collections.sort(nodes, Comparators.NODE_COMPARATOR);
    if (outputJson()) {
        print("%s", json(service, nodes));
    } else {
        ControllerNode self = service.getLocalNode();
        for (ControllerNode node : nodes) {
            DateTime lastUpdated = service.getLastUpdated(node.id());
            String timeAgo = "Never";
            if (lastUpdated != null) {
                timeAgo = Tools.timeAgo(lastUpdated.getMillis());
            }
            print(FMT, node.id(), node.ip(), node.tcpPort(),
                  service.getState(node.id()), timeAgo,
                  node.equals(self) ? "*" : "");
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:NodesListCommand.java


示例4: modified

import org.onlab.util.Tools; //导入依赖的package包/类
@Modified
protected void modified(ComponentContext context) {
    Dictionary<?, ?> properties = context.getProperties();
    String updatedUrl;

    updatedUrl = Tools.get(properties, VTN_SERVICE_URL);
    if (!Strings.isNullOrEmpty(updatedUrl) && !updatedUrl.equals(vtnServiceUrl)) {
        vtnServiceUrl = updatedUrl;
        vtnServiceApi = new DefaultVtnServiceApi(vtnServiceUrl, access);
    }

   updatedUrl = Tools.get(properties, VTN_PORT_URL);
    if (!Strings.isNullOrEmpty(updatedUrl) && !updatedUrl.equals(vtnPortUrl)) {
        vtnPortUrl = updatedUrl;
        vtnPortApi = new DefaultVtnPortApi(vtnPortUrl, access);
    }

    log.info("Modified");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:XosClient.java


示例5: readComponentConfiguration

import org.onlab.util.Tools; //导入依赖的package包/类
/**
 * Extracts properties from the component configuration context.
 *
 * @param context the component context
 */
private void readComponentConfiguration(ComponentContext context) {
    Dictionary<?, ?> properties = context.getProperties();

    String newXosServerAddress =
            Tools.get(properties, XOS_SERVER_ADDRESS_PROPERTY_NAME);
    if (!isNullOrEmpty(newXosServerAddress)) {
        xosServerAddress = newXosServerAddress;
    }

    String newXosServerPortString =
            Tools.get(properties, XOS_SERVER_PORT_PROPERTY_NAME);
    if (!isNullOrEmpty(newXosServerPortString)) {
        xosServerPort = Integer.parseInt(newXosServerPortString);
    }

    String newXosProviderServiceString =
            Tools.get(properties, XOS_PROVIDER_SERVICE_PROPERTY_NAME);
    if (!isNullOrEmpty(newXosProviderServiceString)) {
        xosProviderService = Integer.parseInt(newXosProviderServiceString);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:OnosXosIntegrationManager.java


示例6: readComponentConfiguration

import org.onlab.util.Tools; //导入依赖的package包/类
/**
 * Extracts properties from the component configuration context.
 *
 * @param context the component context
 */
private void readComponentConfiguration(ComponentContext context) {
    Dictionary<?, ?> properties = context.getProperties();

    String metricNameStr = Tools.get(properties, "metricNames");
    metricNames = metricNameStr != null ? metricNameStr : DEFAULT_METRIC_NAMES;
    log.info("Configured. Metric name is {}", metricNames);

    Boolean monitorAllEnabled = Tools.isPropertyEnabled(properties, "monitorAll");
    if (monitorAllEnabled == null) {
        log.info("Monitor all metrics is not configured, " +
                "using current value of {}", monitorAll);
    } else {
        monitorAll = monitorAllEnabled;
        log.info("Configured. Monitor all metrics is {}",
                monitorAll ? "enabled" : "disabled");
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:DefaultInfluxDbMetricsReporter.java


示例7: execute

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
protected void execute() {
    PimInterfaceService interfaceService = get(PimInterfaceService.class);

    Set<PimInterface> interfaces = interfaceService.getPimInterfaces();

    for (PimInterface intf : interfaces) {
        print(INTF_FORMAT, intf.getInterface().name(), intf.getIpAddress());
        for (PimNeighbor neighbor : intf.getNeighbors()) {
            // Filter out the PIM neighbor representing 'us'
            if (!neighbor.ipAddress().equals(intf.getIpAddress())) {
                print(NEIGHBOR_FORMAT, neighbor.ipAddress(),
                        Tools.timeAgo(neighbor.upTime()), neighbor.holdtime(),
                        neighbor.priority(), neighbor.generationId());
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:PimNeighborsListCommand.java


示例8: formCluster

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
public void formCluster(Set<ControllerNode> nodes) {
    checkNotNull(nodes, "Nodes cannot be null");
    checkArgument(!nodes.isEmpty(), "Nodes cannot be empty");

    ClusterMetadata metadata = new ClusterMetadata("default", nodes, buildDefaultPartitions(nodes));
    clusterMetadataAdminService.setClusterMetadata(metadata);
    try {
        log.warn("Shutting down container for cluster reconfiguration!");
        // Clean up persistent state associated with previous cluster configuration.
        Tools.removeDirectory(System.getProperty("karaf.data") + "/partitions");
        systemService.reboot("now", SystemService.Swipe.NONE);
    } catch (Exception e) {
        log.error("Unable to reboot container", e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:ClusterManager.java


示例9: modified

import org.onlab.util.Tools; //导入依赖的package包/类
@Modified
public void modified(ComponentContext context) {
    if (context == null) {
        log.info("Settings: useFlowObjectives={}", useFlowObjectives);
        return;
    }

    boolean newFlowObjectives;
    try {
        String s = Tools.get(context.getProperties(), "useFlowObjectives");
        newFlowObjectives = isNullOrEmpty(s) ? useFlowObjectives : Boolean.parseBoolean(s.trim());
    } catch (ClassCastException e) {
        newFlowObjectives = useFlowObjectives;
    }

    if (useFlowObjectives != newFlowObjectives) {
        useFlowObjectives = newFlowObjectives;
        changeCompilers();
        log.info("Settings: useFlowObjectives={}", useFlowObjectives);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:IntentConfigurableRegistrator.java


示例10: findOpticalConnectivityIntent

import org.onlab.util.Tools; //导入依赖的package包/类
/**
 * Returns existing and available optical connectivity intent that matches the given circuit intent.
 *
 * @param src source connect point of optical circuit intent
 * @param dst destination connect point of optical circuit intent
 * @param signalType signal type of optical circuit intent
 * @param multiplexingSupported indicates whether ODU multiplexing is supported
 * @return existing optical connectivity intent, null otherwise.
 */
private OpticalConnectivityIntent findOpticalConnectivityIntent(ConnectPoint src,
                                                                ConnectPoint dst,
                                                                CltSignalType signalType,
                                                                boolean multiplexingSupported) {

    OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(signalType);

    return Tools.stream(intentService.getIntents())
            .filter(x -> x instanceof OpticalConnectivityIntent)
            .map(x -> (OpticalConnectivityIntent) x)
            .filter(x -> src.deviceId().equals(x.getSrc().deviceId()))
            .filter(x -> dst.deviceId().equals(x.getDst().deviceId()))
            .filter(x -> isAllowed(src, x.getSrc()))
            .filter(x -> isAllowed(dst, x.getDst()))
            .filter(x -> isAvailable(x.id()))
            .filter(x -> !multiplexingSupported ||
                    isAvailableTributarySlots(x.getSrc(), x.getDst(), oduSignalType.tributarySlots()))
            .findFirst()
            .orElse(null);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:OpticalCircuitIntentCompiler.java


示例11: readComponentConfiguration

import org.onlab.util.Tools; //导入依赖的package包/类
/**
 * Extracts properties from the component configuration context.
 *
 * @param context the component context
 */
private void readComponentConfiguration(ComponentContext context) {
    Dictionary<?, ?> properties = context.getProperties();

    Integer newPendingFutureTimeoutMinutes =
            Tools.getIntegerProperty(properties, "pendingFutureTimeoutMinutes");
    if (newPendingFutureTimeoutMinutes == null) {
        pendingFutureTimeoutMinutes = DEFAULT_PENDING_FUTURE_TIMEOUT_MINUTES;
        log.info("Pending future timeout is not configured, " +
                         "using current value of {}", pendingFutureTimeoutMinutes);
    } else {
        pendingFutureTimeoutMinutes = newPendingFutureTimeoutMinutes;
        log.info("Configured. Pending future timeout is configured to {}",
                 pendingFutureTimeoutMinutes);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:SimpleFlowRuleStore.java


示例12: addListener

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
public CompletableFuture<Void> addListener(AtomicValueEventListener<String> listener) {
    // TODO: synchronization
    if (mapEventListener == null) {
        mapEventListener = event -> {
            Versioned<byte[]> newValue = event.newValue();
            Versioned<byte[]> oldValue = event.oldValue();
            if (Objects.equals(event.key(), name)) {
                listener.event(new AtomicValueEvent<>(name,
                        newValue == null ? null : Tools.toStringUtf8(newValue.value()),
                        oldValue == null ? null : Tools.toStringUtf8(oldValue.value())));
            }
        };
        return atomixMap.addListener(mapEventListener).whenComplete((r, e) -> {
            if (e == null) {
                listeners.add(listener);
            } else {
                mapEventListener = null;
            }
        });
    } else {
        listeners.add(listener);
        return CompletableFuture.completedFuture(null);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:AtomixValue.java


示例13: prepare

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> prepare(MapTransaction<K, V> transaction) {

    Map<AsyncConsistentMap<K, V>, List<MapUpdate<K, V>>> updatesGroupedByMap = Maps.newIdentityHashMap();
    transaction.updates().forEach(update -> {
        AsyncConsistentMap<K, V> map = getMap(update.key());
        updatesGroupedByMap.computeIfAbsent(map, k -> Lists.newLinkedList()).add(update);
    });
    Map<AsyncConsistentMap<K, V>, MapTransaction<K, V>> transactionsByMap =
            Maps.transformValues(updatesGroupedByMap,
                                 list -> new MapTransaction<>(transaction.transactionId(), list));

    return Tools.allOf(transactionsByMap.entrySet()
                     .stream()
                     .map(e -> e.getKey().prepare(e.getValue()))
                     .collect(Collectors.toList()))
                .thenApply(list -> list.stream().reduce(Boolean::logicalAnd).orElse(true));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:PartitionedAsyncConsistentMap.java


示例14: prepareAndCommit

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> prepareAndCommit(MapTransaction<K, V> transaction) {
    Map<AsyncConsistentMap<K, V>, List<MapUpdate<K, V>>> updatesGroupedByMap = Maps.newIdentityHashMap();
    transaction.updates().forEach(update -> {
        AsyncConsistentMap<K, V> map = getMap(update.key());
        updatesGroupedByMap.computeIfAbsent(map, k -> Lists.newLinkedList()).add(update);
    });
    Map<AsyncConsistentMap<K, V>, MapTransaction<K, V>> transactionsByMap =
            Maps.transformValues(updatesGroupedByMap,
                                 list -> new MapTransaction<>(transaction.transactionId(), list));

    return Tools.allOf(transactionsByMap.entrySet()
                                        .stream()
                                        .map(e -> e.getKey().prepareAndCommit(e.getValue()))
                                        .collect(Collectors.toList()))
                .thenApply(list -> list.stream().reduce(Boolean::logicalAnd).orElse(true));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:PartitionedAsyncConsistentMap.java


示例15: getFlowEntry

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
public FlowEntry getFlowEntry(FlowRule rule) {
    NodeId master = mastershipService.getMasterFor(rule.deviceId());

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

    if (Objects.equals(local, master)) {
        return flowTable.getFlowEntry(rule);
    }

    log.trace("Forwarding getFlowEntry to {}, which is the primary (master) for device {}",
              master, rule.deviceId());

    return Tools.futureGetOrElse(clusterCommunicator.sendAndReceive(rule,
                                FlowStoreMessageSubjects.GET_FLOW_ENTRY,
                                SERIALIZER::encode,
                                SERIALIZER::decode,
                                master),
                           FLOW_RULE_STORE_TIMEOUT_MILLIS,
                           TimeUnit.MILLISECONDS,
                           null);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:DistributedFlowRuleStore.java


示例16: getFlowEntries

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) {
    NodeId master = mastershipService.getMasterFor(deviceId);

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

    if (Objects.equals(local, master)) {
        return flowTable.getFlowEntries(deviceId);
    }

    log.trace("Forwarding getFlowEntries to {}, which is the primary (master) for device {}",
              master, deviceId);

    return Tools.futureGetOrElse(clusterCommunicator.sendAndReceive(deviceId,
                                FlowStoreMessageSubjects.GET_DEVICE_FLOW_ENTRIES,
                                SERIALIZER::encode,
                                SERIALIZER::decode,
                                master),
                           FLOW_RULE_STORE_TIMEOUT_MILLIS,
                           TimeUnit.MILLISECONDS,
                           Collections.emptyList());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:DistributedFlowRuleStore.java


示例17: unicast

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
public <M> CompletableFuture<Void> unicast(M message,
                                           MessageSubject subject,
                                           Function<M, byte[]> encoder,
                                           NodeId toNodeId) {
    checkPermission(CLUSTER_WRITE);
    try {
        byte[] payload = new ClusterMessage(
                localNodeId,
                subject,
                timeFunction(encoder, subjectMeteringAgent, SERIALIZING).apply(message)
                ).getBytes();
        return doUnicast(subject, payload, toNodeId);
    } catch (Exception e) {
        return Tools.exceptionalFuture(e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:ClusterCommunicationManager.java


示例18: sendAndReceive

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
public <M, R> CompletableFuture<R> sendAndReceive(M message,
                                                  MessageSubject subject,
                                                  Function<M, byte[]> encoder,
                                                  Function<byte[], R> decoder,
                                                  NodeId toNodeId) {
    checkPermission(CLUSTER_WRITE);
    try {
        ClusterMessage envelope = new ClusterMessage(
                clusterService.getLocalNode().id(),
                subject,
                timeFunction(encoder, subjectMeteringAgent, SERIALIZING).
                        apply(message));
        return sendAndReceive(subject, envelope.getBytes(), toNodeId).
                thenApply(bytes -> timeFunction(decoder, subjectMeteringAgent, DESERIALIZING).apply(bytes));
    } catch (Exception e) {
        return Tools.exceptionalFuture(e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:ClusterCommunicationManager.java


示例19: getCurrentStatistic

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
public Set<FlowEntry> getCurrentStatistic(ConnectPoint connectPoint) {
    final DeviceId deviceId = connectPoint.deviceId();
    NodeId master = mastershipService.getMasterFor(deviceId);
    if (master == null) {
        log.warn("No master for {}", deviceId);
        return Collections.emptySet();
    }
    if (master.equals(clusterService.getLocalNode().id())) {
        return getCurrentStatisticInternal(connectPoint);
    } else {
        return Tools.futureGetOrElse(clusterCommunicator.sendAndReceive(
                                    connectPoint,
                                    GET_CURRENT,
                                    SERIALIZER::encode,
                                    SERIALIZER::decode,
                                    master),
                               STATISTIC_STORE_TIMEOUT_MILLIS,
                               TimeUnit.MILLISECONDS,
                               Collections.emptySet());
    }

}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:DistributedStatisticStore.java


示例20: getPreviousStatistic

import org.onlab.util.Tools; //导入依赖的package包/类
@Override
public Set<FlowEntry> getPreviousStatistic(ConnectPoint connectPoint) {
    final DeviceId deviceId = connectPoint.deviceId();
    NodeId master = mastershipService.getMasterFor(deviceId);
    if (master == null) {
        log.warn("No master for {}", deviceId);
        return Collections.emptySet();
    }
    if (master.equals(clusterService.getLocalNode().id())) {
        return getPreviousStatisticInternal(connectPoint);
    } else {
        return Tools.futureGetOrElse(clusterCommunicator.sendAndReceive(
                                    connectPoint,
                                    GET_PREVIOUS,
                                    SERIALIZER::encode,
                                    SERIALIZER::decode,
                                    master),
                               STATISTIC_STORE_TIMEOUT_MILLIS,
                               TimeUnit.MILLISECONDS,
                               Collections.emptySet());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:DistributedStatisticStore.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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