當前位置: 首頁>>代碼示例>>Java>>正文


Java Bandwidth類代碼示例

本文整理匯總了Java中org.onlab.util.Bandwidth的典型用法代碼示例。如果您正苦於以下問題:Java Bandwidth類的具體用法?Java Bandwidth怎麽用?Java Bandwidth使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Bandwidth類屬於org.onlab.util包,在下文中一共展示了Bandwidth類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateRegistration

import org.onlab.util.Bandwidth; //導入依賴的package包/類
private boolean updateRegistration(ConnectPoint cp, BandwidthCapacity bwCapacity) {
    // FIXME workaround until replace/update semantics become available
    // this potentially blows up existing registration
    // or end up as no-op
    //
    // Current code end up in situation like below:
    //        PortNumber: 2
    //        MplsLabel: [[16‥240)]
    //        VlanId: [[0‥4095)]
    //        Bandwidth: 2000000.000000
    //        Bandwidth: 20000000.000000
    //
    // but both unregisterResources(..) and  registerResources(..)
    // returns true (success)

    if (!adminService.unregister(
            Resources.continuous(cp.deviceId(), cp.port(), Bandwidth.class).id())) {
        log.warn("unregisterResources for {} failed", cp);
    }
    return adminService.register(Resources.continuous(cp.deviceId(),
            cp.port(),
            Bandwidth.class).resource(bwCapacity.capacity().bps()));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:ResourceNetworkConfigListener.java

示例2: testBandwidthConstrainedIntentSuccess

import org.onlab.util.Bandwidth; //導入依賴的package包/類
/**
 * Tests that requests with sufficient available bandwidth succeed.
 */
@Test
public void testBandwidthConstrainedIntentSuccess() {

    final ResourceService resourceService =
            IntentTestsMocks.MockResourceService.makeBandwidthResourceService(1000.0);
    final List<Constraint> constraints =
            Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(100.0)));

    final PointToPointIntent intent = makeIntent("s1", "s3", constraints);

    String[] hops = {"s1", "s2", "s3"};
    final PointToPointIntentCompiler compiler = makeCompiler(hops, resourceService);

    final List<Intent> compiledIntents = compiler.compile(intent, null);

    assertThat(compiledIntents, Matchers.notNullValue());
    assertThat(compiledIntents, hasSize(1));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:22,代碼來源:PointToPointIntentCompilerTest.java

示例3: buildAnnotations

import org.onlab.util.Bandwidth; //導入依賴的package包/類
/**
 * Builds the annotation details.
 *
 * @param annotationBuilder default annotation builder instance
 * @param isisLink          ISIS link instance
 * @return annotation builder instance
 */
private DefaultAnnotations.Builder buildAnnotations(DefaultAnnotations.Builder annotationBuilder,
                                                    IsisLink isisLink) {
    int administrativeGroup = 0;
    long teMetric = 0;
    Bandwidth maxReservableBandwidth = Bandwidth.bps(0);
    String routerId = null;
    String neighborId = null;

    //TE Info
    IsisLinkTed isisLinkTed = isisLink.linkTed();
    log.info("Ted Information:  {}", isisLinkTed.toString());
    administrativeGroup = isisLinkTed.administrativeGroup();
    teMetric = isisLinkTed.teDefaultMetric();
    maxReservableBandwidth = isisLinkTed.maximumReservableLinkBandwidth();
    routerId = isisLink.localSystemId();
    neighborId = isisLink.remoteSystemId();
    annotationBuilder.set(ADMINISTRATIVEGROUP, String.valueOf(administrativeGroup));
    annotationBuilder.set(TE_METRIC, String.valueOf(teMetric));
    annotationBuilder.set(MAXRESERVABLEBANDWIDTH, String.valueOf(maxReservableBandwidth));
    annotationBuilder.set(ROUTERID, String.valueOf(routerId));
    annotationBuilder.set(NEIGHBORID, String.valueOf(neighborId));
    return annotationBuilder;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:31,代碼來源:IsisTopologyProvider.java

示例4: registerBandwidth

import org.onlab.util.Bandwidth; //導入依賴的package包/類
/**
 * Registers the bandwidth for source and destination points.
 *
 * @param linkDes  link description instance
 * @param isisLink ISIS link instance
 */
private void registerBandwidth(LinkDescription linkDes, IsisLink isisLink) {
    if (isisLink == null) {
        log.error("Could not able to register bandwidth ");
        return;
    }
    IsisLinkTed isisLinkTed = isisLink.linkTed();
    Bandwidth maxReservableBw = isisLinkTed.maximumReservableLinkBandwidth();
    if (maxReservableBw != null) {
        if (maxReservableBw.compareTo(Bandwidth.bps(0)) == 0) {
            return;
        }
        //Configure bandwidth for src and dst port
        BandwidthCapacity config = networkConfigService.addConfig(linkDes.src(), BandwidthCapacity.class);
        config.capacity(maxReservableBw).apply();

        config = networkConfigService.addConfig(linkDes.dst(), BandwidthCapacity.class);
        config.capacity(maxReservableBw).apply();
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:26,代碼來源:IsisTopologyProvider.java

示例5: printAllocation

import org.onlab.util.Bandwidth; //導入依賴的package包/類
private void printAllocation(DeviceId did, PortNumber num, int level) {
    if (level == 0) {
        // print DeviceId when Port was directly specified.
        print("%s", did);
    }
    print("%s%s", Strings.repeat(" ", level), asVerboseString(num));

    // FIXME: This workaround induces a lot of distributed store access.
    //        ResourceService should have an API to get all allocations under a parent resource.
    Set<Class<?>> subResourceTypes = ImmutableSet.<Class<?>>builder()
            .add(OchSignal.class)
            .add(VlanId.class)
            .add(MplsLabel.class)
            .add(Bandwidth.class)
            .add(TributarySlot.class)
            .build();

    DiscreteResourceId resourceId = Resources.discrete(did, num).id();
    for (Class<?> t : subResourceTypes) {
        resourceService.getResourceAllocations(resourceId, t).stream()
                .filter(a -> isSubjectToPrint(a))
                .forEach(a -> print("%s%s allocated by %s", Strings.repeat(" ", level + 1),
                        a.resource().valueAs(Object.class).orElse(""), asVerboseString(a.consumerId())));

    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:27,代碼來源:AllocationsCommand.java

示例6: testBandwidthConstrainedIntentFailure

import org.onlab.util.Bandwidth; //導入依賴的package包/類
/**
 * Tests that requests with insufficient available bandwidth fail.
 */
@Test
public void testBandwidthConstrainedIntentFailure() {

    final ResourceService resourceService =
            IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0);
    final List<Constraint> constraints =
            Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(100.0)));

    try {
        final PointToPointIntent intent = makeIntent("s1", "s3", constraints);

        String[] hops = {"s1", "s2", "s3"};
        final PointToPointIntentCompiler compiler = makeCompiler(hops, resourceService);

        compiler.compile(intent, null);

        fail("Point to Point compilation with insufficient bandwidth does "
                + "not throw exception.");
    } catch (PathNotFoundException noPath) {
        assertThat(noPath.getMessage(), containsString("No path"));
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:26,代碼來源:PointToPointIntentCompilerTest.java

示例7: updateBandwidthUsage

import org.onlab.util.Bandwidth; //導入依賴的package包/類
/**
 * Updates usage information of bandwidth based on connectivity which is established.
 * @param connectivity Optical connectivity
 */
private void updateBandwidthUsage(OpticalConnectivity connectivity) {
    OpticalConnectivityId connectivityId = connectivity.id();

    List<Link> links = connectivity.links();

    List<Resource> resources = links.stream().flatMap(l -> Stream.of(l.src(), l.dst()))
            .filter(cp -> !isTransportLayer(deviceService.getDevice(cp.deviceId()).type()))
            .map(cp -> Resources.continuous(cp.deviceId(), cp.port(),
                    Bandwidth.class).resource(connectivity.bandwidth().bps()))
            .collect(Collectors.toList());

    log.debug("allocating bandwidth for {} : {}", connectivityId, resources);
    List<ResourceAllocation> allocations = resourceService.allocate(connectivityId, resources);
    if (allocations.isEmpty()) {
        log.warn("Failed to allocate bandwidth {} to {}",
                connectivity.bandwidth().bps(), resources);
        // TODO any recovery?
    }
    log.debug("Done allocating bandwidth for {}", connectivityId);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:25,代碼來源:OpticalPathProvisioner.java

示例8: hasEnoughBandwidth

import org.onlab.util.Bandwidth; //導入依賴的package包/類
private boolean hasEnoughBandwidth(ConnectPoint cp) {
    if (cp.elementId() instanceof DeviceId) {
        Device device =  deviceService.getDevice(cp.deviceId());
        Device.Type type = device.type();

        if (isTransportLayer(type)) {
            // Check if the port has enough capacity
            Port port = deviceService.getPort(cp.deviceId(), cp.port());
            if (port instanceof OduCltPort || port instanceof OchPort) {
                // Port with capacity
                return bandwidth.bps() < port.portSpeed() * 1000000.0;
            } else {
                // Port without valid capacity (OMS port, etc.)
                return true;
            }
        } else {
            // Check if enough amount of bandwidth resource remains
            ContinuousResource resource = Resources.continuous(cp.deviceId(), cp.port(), Bandwidth.class)
                    .resource(bandwidth.bps());
            return resourceService.isAvailable(resource);
        }
    }
    return false;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:25,代碼來源:OpticalPathProvisioner.java

示例9: updateCrossConnectLink

import org.onlab.util.Bandwidth; //導入依賴的package包/類
private void updateCrossConnectLink(Intent intent) {
    linkPathMap.entrySet().stream()
            .filter(e -> e.getKey().realizingIntentKey().equals(intent.key()))
            .forEach(e -> {
                ConnectPoint packetSrc = e.getKey().src();
                ConnectPoint packetDst = e.getKey().dst();
                Bandwidth bw = e.getKey().bandwidth();
                // Updates bandwidth of packet ports
                updatePortBandwidth(packetSrc, bw);
                updatePortBandwidth(packetDst, bw);

                OpticalConnectivity connectivity = e.getValue();
                connectivity.setLinkEstablished(packetSrc, packetDst);

                if (e.getValue().isAllRealizingLinkEstablished()) {
                    updateBandwidthUsage(connectivity);

                    // Notifies listeners if all links are established
                    post(new OpticalPathEvent(OpticalPathEvent.Type.PATH_INSTALLED, e.getValue().id()));
                }
            });
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:23,代碼來源:OpticalPathProvisioner.java

示例10: execute

import org.onlab.util.Bandwidth; //導入依賴的package包/類
@Override
protected void execute() {
    OpticalPathService opticalPathService = get(OpticalPathService.class);

    ConnectPoint ingress = readConnectPoint(ingressStr);
    ConnectPoint egress = readConnectPoint(egressStr);
    if (ingress == null || egress == null) {
        print("Invalid connect points: %s, %s", ingressStr, egressStr);
        return;
    }

    Bandwidth bandwidth = (bandwidthStr == null || bandwidthStr.isEmpty()) ? null :
            Bandwidth.bps(Long.valueOf(bandwidthStr));

    print("Trying to setup connectivity between %s and %s.", ingress, egress);
    OpticalConnectivityId id = opticalPathService.setupConnectivity(ingress, egress, bandwidth, null);
    if (id == null) {
        print("Failed.");
        return;
    }
    print("Optical path ID : %s", id.id());
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:23,代碼來源:AddOpticalConnectivityCommand.java

示例11: LinkTed

import org.onlab.util.Bandwidth; //導入依賴的package包/類
/**
 * Constructor to initialize its parameter.
 *
 * @param maximumLink maximum bandwidth can be used
 * @param maxReserved max bandwidth that can be reserved
 * @param maxUnResBandwidth amount of bandwidth reservable
 * @param teMetric Traffic engineering metric
 * @param igpMetric IGP metric
 * @param color information on administrative group assigned to the interface
 * @param signalType MPLS signaling protocols
 * @param srlgGroup Shared Risk Link Group information
 * @param protectType protection capabilities of the link
 * @param ipv4LocRouterId IPv4 router-Id of local node
 * @param ipv6LocRouterId IPv6 router-Id of local node
 * @param ipv4RemRouterId IPv4 router-Id of remote node
 * @param ipv6RemRouterId IPv6 router-Id of remote node
 */
public LinkTed(Bandwidth maximumLink, Bandwidth maxReserved, List<Bandwidth> maxUnResBandwidth,
               Metric teMetric, Metric igpMetric, Color color, Signalling signalType, List<Srlg> srlgGroup,
               ProtectionType protectType, List<Ip4Address> ipv4LocRouterId, List<Ip6Address> ipv6LocRouterId,
               List<Ip4Address> ipv4RemRouterId, List<Ip6Address> ipv6RemRouterId) {
    this.maximumLink = maximumLink;
    this.maxReserved = maxReserved;
    this.maxUnResBandwidth = maxUnResBandwidth;
    this.teMetric = teMetric;
    this.igpMetric = igpMetric;
    this.color = color;
    this.signalType = signalType;
    this.srlgGroup = srlgGroup;
    this.protectType = protectType;
    this.ipv4LocRouterId = ipv4LocRouterId;
    this.ipv6LocRouterId = ipv6LocRouterId;
    this.ipv4RemRouterId = ipv4RemRouterId;
    this.ipv6RemRouterId = ipv6RemRouterId;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:36,代碼來源:LinkTed.java

示例12: releaseSharedBandwidth

import org.onlab.util.Bandwidth; //導入依賴的package包/類
/**
 *  Re-allocates the bandwidth for the tunnel for which the bandwidth was
 *  allocated in shared mode initially.
 */
private synchronized void releaseSharedBandwidth(Tunnel newTunnel, Tunnel oldTunnel) {
    // 1. Release old tunnel's bandwidth.
    resourceService.release(pceStore.getTunnelInfo(oldTunnel.tunnelId()).tunnelConsumerId());

    // 2. Release new tunnel's bandwidth
    ResourceConsumer consumer = pceStore.getTunnelInfo(newTunnel.tunnelId()).tunnelConsumerId();
    resourceService.release(consumer);

    // 3. Allocate new tunnel's complete bandwidth.
    double bandwidth = Double.parseDouble(newTunnel.annotations().value(BANDWIDTH));
    Resource resource;

    for (Link link : newTunnel.path().links()) {
        resource = Resources.continuous(link.src().deviceId(), link.src().port(), Bandwidth.class)
                .resource(bandwidth);
        resourceService.allocate(consumer, resource); // Reusing new tunnel's TunnelConsumerId intentionally.

    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:PceManager.java

示例13: setupPathTest11

import org.onlab.util.Bandwidth; //導入依賴的package包/類
/**
 * Tests path setup without failure for LSP with signalling and with bandwidth reservation.
 */
@Test
public void setupPathTest11() {
    build4RouterTopo(false, true, true, true, 15);
    List<Constraint> constraints = new LinkedList<Constraint>();
    BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(10.0));
    CostConstraint costConstraint = new CostConstraint(TE_COST);

    constraints.add(costConstraint);
    constraints.add(bwConstraint);

    LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
    LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);

    pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
    pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);

    boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, SR_WITHOUT_SIGNALLING);
    assertThat(result, is(false));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:23,代碼來源:PceManagerTest.java

示例14: queryBandwidth

import org.onlab.util.Bandwidth; //導入依賴的package包/類
/**
 * Query bandwidth capacity on a port.
 *
 * @param did {@link DeviceId}
 * @param number {@link PortNumber}
 * @return bandwidth capacity
 */
private Optional<Bandwidth> queryBandwidth(DeviceId did, PortNumber number) {
    // Check and use netcfg first.
    ConnectPoint cp = new ConnectPoint(did, number);
    BandwidthCapacity config = netcfgService.getConfig(cp, BandwidthCapacity.class);
    if (config != null) {
        log.trace("Registering configured bandwidth {} for {}/{}", config.capacity(), did, number);
        return Optional.of(config.capacity());
    }

    // populate bandwidth value, assuming portSpeed == bandwidth
    Port port = deviceService.getPort(did, number);
    if (port != null) {
        return Optional.of(Bandwidth.mbps(port.portSpeed()));
    }
    return Optional.empty();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:ResourceDeviceListener.java

示例15: testMaximumLink

import org.onlab.util.Bandwidth; //導入依賴的package包/類
/**
 * Tests maximumLink() getter method.
 */
@Test
public void testMaximumLink() throws Exception {

    ospfLinkTed.setMaximumLink(Bandwidth.bps(1234));
    assertThat(ospfLinkTed.maximumLink(), is(Bandwidth.bps(1234)));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:10,代碼來源:OspfLinkTedImplTest.java


注:本文中的org.onlab.util.Bandwidth類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。