コード例 #1
0
  /**
   * Update details of a specified path id.
   *
   * @param id path id
   * @param stream pce path from json
   * @return 200 OK, 404 if given identifier does not exist
   */
  @PUT
  @Path("{path_id}")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public Response updatePath(@PathParam("path_id") String id, final InputStream stream) {
    log.debug("Update path by identifier {}.", id);
    try {
      ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
      JsonNode pathNode = jsonTree.get("path");
      PcePath path = codec(PcePath.class).decode((ObjectNode) pathNode, this);
      // Assign cost
      List<Constraint> constrntList = new LinkedList<Constraint>();
      // TODO: need to uncomment below lines once CostConstraint class is ready
      if (path.costConstraint() != null) {
        // CostConstraint.Type costType = CostConstraint.Type.values()[path.constraint().cost()];
        // constrntList.add(CostConstraint.of(costType));
      }

      // Assign bandwidth. Data rate unit is in BPS.
      if (path.bandwidthConstraint() != null) {
        // TODO: need to uncomment below lines once BandwidthConstraint class is ready
        // constrntList.add(LocalBandwidthConstraint
        //        .of(path.constraint().bandwidth(), DataRateUnit.valueOf("BPS")));
      }

      Boolean result =
          nullIsNotFound(
              get(PceService.class).updatePath(TunnelId.valueOf(id), constrntList),
              PCE_PATH_NOT_FOUND);
      return Response.status(OK).entity(result.toString()).build();
    } catch (IOException e) {
      log.error("Update path failed because of exception {}.", e.toString());
      throw new IllegalArgumentException(e);
    }
  }
コード例 #2
0
  @Override
  public boolean removeTunnelInfo(TunnelId tunnelId) {
    checkNotNull(tunnelId, TUNNEL_ID_NULL);

    if (tunnelInfoMap.remove(tunnelId) == null) {
      log.error("Tunnel info deletion for tunnel id {} has failed.", tunnelId.toString());
      return false;
    }
    return true;
  }
コード例 #3
0
 /**
  * Retrieve details of a specified path id.
  *
  * @param id path id
  * @return 200 OK, 404 if given identifier does not exist
  */
 @GET
 @Path("{path_id}")
 @Produces(MediaType.APPLICATION_JSON)
 public Response queryPath(@PathParam("path_id") String id) {
   log.debug("Query path by identifier {}.", id);
   Tunnel tunnel =
       nullIsNotFound(get(PceService.class).queryPath(TunnelId.valueOf(id)), PCE_PATH_NOT_FOUND);
   PcePath path = DefaultPcePath.builder().of(tunnel).build();
   ObjectNode result = mapper().createObjectNode();
   result.set("path", codec(PcePath.class).encode(path, this));
   return ok(result.toString()).build();
 }
コード例 #4
0
  /**
   * Release a specified path.
   *
   * @param id path id
   * @return 200 OK, 404 if given identifier does not exist
   */
  @Path("{path_id}")
  @DELETE
  public Response releasePath(@PathParam("path_id") String id) {
    log.debug("Deletes path by identifier {}.", id);

    Boolean isSuccess =
        nullIsNotFound(get(PceService.class).releasePath(TunnelId.valueOf(id)), PCE_PATH_NOT_FOUND);
    if (!isSuccess) {
      log.debug("Path identifier {} does not exist", id);
    }

    return Response.status(OK).entity(isSuccess.toString()).build();
  }
コード例 #5
0
  @Test
  public void testEquality() {
    DefaultVirtualDevice device1 =
        new DefaultVirtualDevice(NetworkId.networkId(0), DeviceId.deviceId(deviceIdValue1));
    DefaultVirtualDevice device2 =
        new DefaultVirtualDevice(NetworkId.networkId(0), DeviceId.deviceId(deviceIdValue2));
    ConnectPoint src = new ConnectPoint(device1.id(), PortNumber.portNumber(1));
    ConnectPoint dst = new ConnectPoint(device2.id(), PortNumber.portNumber(2));

    DefaultVirtualLink link1 =
        new DefaultVirtualLink(NetworkId.networkId(0), src, dst, TunnelId.valueOf(0));
    DefaultVirtualLink link2 =
        new DefaultVirtualLink(NetworkId.networkId(0), src, dst, TunnelId.valueOf(0));
    DefaultVirtualLink link3 =
        new DefaultVirtualLink(NetworkId.networkId(0), src, dst, TunnelId.valueOf(1));
    DefaultVirtualLink link4 =
        new DefaultVirtualLink(NetworkId.networkId(1), src, dst, TunnelId.valueOf(0));

    new EqualsTester()
        .addEqualityGroup(link1, link2)
        .addEqualityGroup(link3)
        .addEqualityGroup(link4)
        .testEquals();
  }