Sho SHIMIZU
Committed by Thomas Vachuska

Remove constructs deprecated in Emu from old resource API

Change-Id: Ia4fd5d4c45d91b82b78ace18e96512c800adfcd6
Showing 22 changed files with 0 additions and 1656 deletions
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource;
import com.google.common.annotations.Beta;
/**
* Exception thrown for resource allocation errors.
*/
@Beta
public class ResourceAllocationException extends ResourceException {
public ResourceAllocationException() {
super();
}
public ResourceAllocationException(String message) {
super(message);
}
public ResourceAllocationException(String message, Throwable cause) {
super(message, cause);
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource;
import com.google.common.annotations.Beta;
/**
* Represents a resource related error.
*/
@Beta
public class ResourceException extends RuntimeException {
/**
* Constructs an exception with no message and no underlying cause.
*/
public ResourceException() {
}
/**
* Constructs an exception with the specified message.
*
* @param message the message describing the specific nature of the error
*/
public ResourceException(String message) {
super(message);
}
/**
* Constructs an exception with the specified message and the underlying cause.
*
* @param message the message describing the specific nature of the error
* @param cause the underlying cause of this error
*/
public ResourceException(String message, Throwable cause) {
super(message, cause);
}
}
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import org.onlab.util.Bandwidth;
import org.onlab.util.DataRateUnit;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Representation of bandwidth resource in bps.
*
* @deprecated in Emu Release
*/
@Deprecated
public final class BandwidthResource implements LinkResource {
private final Bandwidth bandwidth;
/**
* Creates a new instance with given bandwidth.
*
* @param bandwidth bandwidth value to be assigned
*/
public BandwidthResource(Bandwidth bandwidth) {
this.bandwidth = checkNotNull(bandwidth);
}
// Constructor for serialization
private BandwidthResource() {
this.bandwidth = null;
}
/**
* Creates a new bandwidth resource.
*
* @param v amount of bandwidth to request
* @param unit {@link DataRateUnit} of {@code v}
* @return {@link BandwidthResource} instance with given bandwidth
*/
public static BandwidthResource of(double v, DataRateUnit unit) {
return new BandwidthResource(Bandwidth.of(v, unit));
}
/**
* Returns bandwidth as a double value.
*
* @return bandwidth as a double value
*/
public double toDouble() {
return bandwidth.bps();
}
@Override
public boolean equals(Object obj) {
if (obj instanceof BandwidthResource) {
BandwidthResource that = (BandwidthResource) obj;
return Objects.equals(this.bandwidth, that.bandwidth);
}
return false;
}
@Override
public int hashCode() {
return Objects.hashCode(this.bandwidth);
}
@Override
public String toString() {
return String.valueOf(this.bandwidth);
}
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import com.google.common.base.MoreObjects;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceType;
import java.util.Objects;
/**
* Representation of allocated bandwidth resource.
*
* @deprecated in Emu Release
*/
@Deprecated
public class BandwidthResourceAllocation implements ResourceAllocation {
private final BandwidthResource bandwidth;
/**
* Creates a new {@link BandwidthResourceRequest} with {@link BandwidthResource}
* object.
*
* @param bandwidth {@link BandwidthResource} object to be requested
*/
public BandwidthResourceAllocation(BandwidthResource bandwidth) {
this.bandwidth = bandwidth;
}
/**
* Returns the bandwidth resource.
*
* @return the bandwidth resource
*/
public BandwidthResource bandwidth() {
return bandwidth;
}
@Override
public ResourceType type() {
return ResourceType.BANDWIDTH;
}
@Override
public int hashCode() {
return bandwidth.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final BandwidthResourceAllocation other = (BandwidthResourceAllocation) obj;
return Objects.equals(this.bandwidth, other.bandwidth());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("bandwidth", bandwidth)
.toString();
}
}
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import java.util.Objects;
import com.google.common.base.MoreObjects;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
/**
* Representation of a request for bandwidth resource.
*
* @deprecated in Emu Release
*/
@Deprecated
public class BandwidthResourceRequest implements ResourceRequest {
private final BandwidthResource bandwidth;
/**
* Creates a new {@link BandwidthResourceRequest} with {@link BandwidthResource}
* object.
*
* @param bandwidth {@link BandwidthResource} object to be requested
*/
public BandwidthResourceRequest(BandwidthResource bandwidth) {
this.bandwidth = bandwidth;
}
/**
* Returns the bandwidth resource.
*
* @return the bandwidth resource
*/
public BandwidthResource bandwidth() {
return bandwidth;
}
@Override
public ResourceType type() {
return ResourceType.BANDWIDTH;
}
@Override
public int hashCode() {
return bandwidth.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final BandwidthResourceRequest other = (BandwidthResourceRequest) obj;
return Objects.equals(this.bandwidth, other.bandwidth());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("bandwidth", bandwidth)
.toString();
}
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.onosproject.net.Link;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Map.Entry;
import java.util.Set;
/**
* Implementation of {@link LinkResourceAllocations}.
*
* @deprecated in Emu Release
*/
@Deprecated
public class DefaultLinkResourceAllocations implements LinkResourceAllocations {
private final LinkResourceRequest request;
// TODO: probably should be using LinkKey instead
private final Map<Link, Set<ResourceAllocation>> allocations;
/**
* Creates a new link resource allocations.
*
* @param request requested resources
* @param allocations allocated resources
*/
public DefaultLinkResourceAllocations(LinkResourceRequest request,
Map<Link, Set<ResourceAllocation>> allocations) {
this.request = checkNotNull(request);
ImmutableMap.Builder<Link, Set<ResourceAllocation>> builder
= ImmutableMap.builder();
for (Entry<Link, Set<ResourceAllocation>> e : allocations.entrySet()) {
builder.put(e.getKey(), ImmutableSet.copyOf(e.getValue()));
}
this.allocations = builder.build();
}
public IntentId intentId() {
return request.intentId();
}
public Collection<Link> links() {
return request.links();
}
public Set<ResourceRequest> resources() {
return request.resources();
}
@Override
public ResourceType type() {
return null;
}
@Override
public Set<ResourceAllocation> getResourceAllocation(Link link) {
Set<ResourceAllocation> result = allocations.get(link);
if (result == null) {
result = Collections.emptySet();
}
return result;
}
@Override
public int hashCode() {
return Objects.hash(request, allocations);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final DefaultLinkResourceAllocations other = (DefaultLinkResourceAllocations) obj;
return Objects.equals(this.request, other.request)
&& Objects.equals(this.allocations, other.allocations);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("allocations", allocations)
.toString();
}
}
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.Objects;
import java.util.stream.Collectors;
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableMap;
import org.onlab.util.Bandwidth;
import org.onosproject.net.Link;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Implementation of {@link LinkResourceRequest}.
*
* @deprecated in Emu Release
*/
@Deprecated
public final class DefaultLinkResourceRequest implements LinkResourceRequest {
private final IntentId intentId;
protected final Map<Link, Set<ResourceRequest>> requests;
/**
* Creates a new link resource request with the specified Intent ID,
* and resource requests over links.
*
* @param intentId intent ID associated with this request
* @param requests resource requests over links
*/
private DefaultLinkResourceRequest(IntentId intentId, Map<Link, Set<ResourceRequest>> requests) {
this.intentId = checkNotNull(intentId);
this.requests = checkNotNull(ImmutableMap.copyOf(requests));
}
@Override
public ResourceType type() {
return null;
}
@Override
public IntentId intentId() {
return intentId;
}
@Override
public Collection<Link> links() {
return requests.keySet();
}
@Override
public Set<ResourceRequest> resources() {
return requests.values().stream()
.flatMap(Collection::stream)
.collect(Collectors.toSet());
}
@Override
public Set<ResourceRequest> resources(Link link) {
return requests.get(link);
}
/**
* Returns builder of link resource request.
*
* @param intentId intent ID related to this request
* @param links a set of links for the request
* @return builder of link resource request
*/
public static LinkResourceRequest.Builder builder(
IntentId intentId, Collection<Link> links) {
return new Builder(intentId, links);
}
/**
* Builder of link resource request.
*/
public static final class Builder implements LinkResourceRequest.Builder {
private IntentId intentId;
private Map<Link, Set<ResourceRequest>> requests;
/**
* Creates a new link resource request.
*
* @param intentId intent ID related to this request
* @param links a set of links for the request
*/
private Builder(IntentId intentId, Collection<Link> links) {
this.intentId = intentId;
this.requests = new HashMap<>();
for (Link link : links) {
requests.put(link, new HashSet<>());
}
}
/**
* Adds lambda request.
*
* @return self
* @deprecated in Emu Release
*/
@Deprecated
@Override
public Builder addLambdaRequest() {
for (Link link : requests.keySet()) {
requests.get(link).add(new LambdaResourceRequest());
}
return this;
}
@Beta
@Override
public LinkResourceRequest.Builder addLambdaRequest(LambdaResource lambda) {
for (Link link : requests.keySet()) {
requests.get(link).add(new LambdaResourceRequest(lambda));
}
return this;
}
/**
* Adds Mpls request.
*
* @return self
* @deprecated in Emu Release
*/
@Deprecated
@Override
public Builder addMplsRequest() {
for (Link link : requests.keySet()) {
requests.get(link).add(new MplsLabelResourceRequest());
}
return this;
}
@Beta
@Override
public Builder addMplsRequest(MplsLabel label) {
for (Link link : requests.keySet()) {
requests.get(link).add(new MplsLabelResourceRequest(label));
}
return this;
}
@Beta
@Override
public LinkResourceRequest.Builder addMplsRequest(Map<Link, MplsLabel> labels) {
for (Link link : labels.keySet()) {
if (!requests.containsKey(link)) {
requests.put(link, new HashSet<>());
}
requests.get(link).add(new MplsLabelResourceRequest(labels.get(link)));
}
return this;
}
/**
* Adds bandwidth request with bandwidth value.
*
* @param bandwidth bandwidth value in bits per second to be requested
* @return self
*/
@Override
public Builder addBandwidthRequest(double bandwidth) {
for (Link link : requests.keySet()) {
requests.get(link).add(new BandwidthResourceRequest(new BandwidthResource(Bandwidth.bps(bandwidth))));
}
return this;
}
@Override
public LinkResourceRequest.Builder addConstraint(Constraint constraint) {
if (constraint instanceof BandwidthConstraint) {
BandwidthConstraint bw = (BandwidthConstraint) constraint;
return addBandwidthRequest(bw.bandwidth().bps());
}
return this;
}
/**
* Returns link resource request.
*
* @return link resource request
*/
@Override
public LinkResourceRequest build() {
return new DefaultLinkResourceRequest(intentId, requests);
}
}
@Override
public int hashCode() {
return Objects.hash(intentId, links());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final DefaultLinkResourceRequest other = (DefaultLinkResourceRequest) obj;
return Objects.equals(this.intentId, other.intentId)
&& Objects.equals(this.links(), other.links());
}
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import org.onosproject.net.IndexedLambda;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Representation of lambda resource.
*
* @deprecated in Emu Release
*/
@Deprecated
public final class LambdaResource implements LinkResource {
private final IndexedLambda lambda;
/**
* Creates a new instance with given lambda.
*
* @param lambda lambda to be assigned
*/
private LambdaResource(IndexedLambda lambda) {
this.lambda = checkNotNull(lambda);
}
// Constructor for serialization
private LambdaResource() {
this.lambda = null;
}
/**
* Creates a new instance with the given index of lambda.
*
* @param lambda index value of lambda to be assigned
* @return {@link LambdaResource} instance with the given lambda
*/
public static LambdaResource valueOf(int lambda) {
return valueOf(new IndexedLambda(lambda));
}
/**
* Creates a new instance with the given lambda.
*
* @param lambda lambda to be assigned
* @return {@link LambdaResource} instance with the given lambda
*/
public static LambdaResource valueOf(IndexedLambda lambda) {
return new LambdaResource(lambda);
}
/**
* Returns lambda as an int value.
*
* @return lambda as an int value
*/
public int toInt() {
return (int) lambda.index();
}
@Override
public boolean equals(Object obj) {
if (obj instanceof LambdaResource) {
LambdaResource that = (LambdaResource) obj;
return Objects.equals(this.lambda, that.lambda);
}
return false;
}
@Override
public int hashCode() {
return lambda.hashCode();
}
@Override
public String toString() {
return String.valueOf(this.lambda);
}
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import com.google.common.base.MoreObjects;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceType;
import java.util.Objects;
/**
* Representation of allocated lambda resource.
*
* @deprecated in Emu Release
*/
@Deprecated
public class LambdaResourceAllocation implements ResourceAllocation {
private final LambdaResource lambda;
@Override
public ResourceType type() {
return ResourceType.LAMBDA;
}
/**
* Creates a new {@link LambdaResourceAllocation} with {@link LambdaResource}
* object.
*
* @param lambda allocated lambda
*/
public LambdaResourceAllocation(LambdaResource lambda) {
this.lambda = lambda;
}
/**
* Returns the lambda resource.
*
* @return the lambda resource
*/
public LambdaResource lambda() {
return lambda;
}
@Override
public int hashCode() {
return Objects.hashCode(lambda);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final LambdaResourceAllocation other = (LambdaResourceAllocation) obj;
return Objects.equals(this.lambda, other.lambda);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("lambda", lambda)
.toString();
}
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Representation of a request for lambda resource.
*
* @deprecated in Emu Release
*/
@Deprecated
public class LambdaResourceRequest implements ResourceRequest {
private final LambdaResource lambda;
/**
* Constructs a request specifying the given lambda.
*
* @param lambda lambda to be requested
*/
@Beta
public LambdaResourceRequest(LambdaResource lambda) {
this.lambda = checkNotNull(lambda);
}
/**
* Constructs a request asking an arbitrary available lambda.
*
* @deprecated in Emu Release
*/
@Deprecated
public LambdaResourceRequest() {
this.lambda = null;
}
/**
* Returns the lambda this request expects.
*
* @return the lambda this request expects
*/
@Beta
public LambdaResource lambda() {
return lambda;
}
@Override
public ResourceType type() {
return ResourceType.LAMBDA;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("lambda", lambda)
.toString();
}
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
/**
* Abstraction of link resource.
*
* @deprecated in Emu Release
*/
@Deprecated
public interface LinkResource {
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import java.util.Collection;
import org.onosproject.event.AbstractEvent;
import com.google.common.collect.ImmutableList;
/**
* Describes an event related to a Link Resource.
*
* @deprecated in Emu Release
*/
@Deprecated
public final class LinkResourceEvent
extends AbstractEvent<LinkResourceEvent.Type, Collection<LinkResourceAllocations>> {
/**
* Type of resource this event is for.
*/
public enum Type {
/** Additional resources are now available. */
ADDITIONAL_RESOURCES_AVAILABLE
}
/**
* Constructs a link resource event.
*
* @param type type of resource event to create
* @param linkResourceAllocations allocations that are now available
*/
public LinkResourceEvent(Type type,
Collection<LinkResourceAllocations> linkResourceAllocations) {
super(type, ImmutableList.copyOf(linkResourceAllocations));
}
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import org.onosproject.event.EventListener;
/**
* Entity for receiving link resource events.
*
* @deprecated in Emu Release
*/
@Deprecated
public interface LinkResourceListener extends EventListener<LinkResourceEvent> {
}
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import com.google.common.annotations.Beta;
import org.onosproject.net.Link;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.resource.ResourceRequest;
/**
* Representation of a request for link resource.
*
* @deprecated in Emu Release
*/
@Deprecated
public interface LinkResourceRequest extends ResourceRequest {
/**
* Returns the {@link IntentId} associated with the request.
*
* @return the {@link IntentId} associated with the request
*/
IntentId intentId();
/**
* Returns the set of target links.
*
* @return the set of target links
*/
Collection<Link> links();
/**
* Returns the set of resource requests.
*
* @return the set of resource requests
*/
Set<ResourceRequest> resources();
/**
* Returns the set of resource request against the specified link.
*
* @param link link whose associated resource request is to be returned
* @return set of resource request against the specified link
*/
@Beta
Set<ResourceRequest> resources(Link link);
/**
* Builder of link resource request.
*/
interface Builder {
/**
* Adds lambda request.
*
* @return self
* @deprecated in Emu Release
*/
@Deprecated
Builder addLambdaRequest();
/**
* Adds lambda request.
*
* @param lambda lambda to be requested
* @return self
*/
@Beta
Builder addLambdaRequest(LambdaResource lambda);
/**
* Adds MPLS request.
*
* @return self
* @deprecated in Emu Release
*/
@Deprecated
Builder addMplsRequest();
/**
* Adds MPLS request.
*
* @param label MPLS label to be requested
* @return self
*/
@Beta
Builder addMplsRequest(MplsLabel label);
/**
* Adds MPLS request against the specified links.
*
* @param labels MPLS labels to be requested against links
* @return self
*/
@Beta
Builder addMplsRequest(Map<Link, MplsLabel> labels);
/**
* Adds bandwidth request with bandwidth value.
*
* @param bandwidth bandwidth value to be requested
* @return self
*/
Builder addBandwidthRequest(double bandwidth);
/**
* Adds the resources required for a constraint.
*
* @param constraint the constraint
* @return self
*/
Builder addConstraint(Constraint constraint);
/**
* Returns link resource request.
*
* @return link resource request
*/
LinkResourceRequest build();
}
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import org.onosproject.store.StoreDelegate;
/**
* Link resource store delegate abstraction.
*
* @deprecated in Emu Release
*/
@Deprecated
public interface LinkResourceStoreDelegate extends StoreDelegate<LinkResourceEvent> {
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import java.util.Set;
/**
* Abstraction of a resources of a link.
*
* @deprecated in Emu Release
*/
@Deprecated
public interface LinkResources {
/**
* Returns resources as a set of {@link LinkResource}s.
*
* @return a set of {@link LinkResource}s
*/
Set<LinkResource> resources();
/**
* Builder of {@link LinkResources}.
*
* @deprecated in Emu Release
*/
@Deprecated
interface Builder {
/**
* Adds bandwidth resource.
* <p>
* This operation adds given bandwidth to previous bandwidth and
* generates single bandwidth resource.
*
* @param bandwidth bandwidth value to be added
* @return self
*/
Builder addBandwidth(double bandwidth);
/**
* Adds lambda resource.
*
* @param lambda lambda value to be added
* @return self
*/
Builder addLambda(int lambda);
/**
* Builds an immutable link resources.
*
* @return link resources
*/
LinkResources build();
}
}
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import java.util.Objects;
/**
* Representation of MPLS label resource.
*
* @deprecated in Emu Release
*/
@Deprecated
public final class MplsLabel implements LinkResource {
private final org.onlab.packet.MplsLabel mplsLabel;
/**
* Creates a new instance with given MPLS label.
*
* @param mplsLabel MPLS Label value to be assigned
*/
public MplsLabel(int mplsLabel) {
this.mplsLabel = org.onlab.packet.MplsLabel.mplsLabel(mplsLabel);
}
/**
* Creates a new instance with given MPLS label.
*
* @param mplsLabel mplsLabel value to be assigned
* @return {@link MplsLabel} instance with given bandwidth
*/
public static MplsLabel valueOf(int mplsLabel) {
return new MplsLabel(mplsLabel);
}
/**
* Returns MPLS Label as an MPLS Label Object.
*
* @return MPLS label as an MPLS Label Object.
*/
public org.onlab.packet.MplsLabel label() {
return mplsLabel;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof MplsLabel) {
MplsLabel that = (MplsLabel) obj;
return Objects.equals(this.mplsLabel, that.mplsLabel);
}
return false;
}
@Override
public int hashCode() {
return Objects.hashCode(this.mplsLabel);
}
@Override
public String toString() {
return String.valueOf(this.mplsLabel);
}
}
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import com.google.common.base.MoreObjects;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceType;
import java.util.Objects;
/**
* Representation of allocated MPLS label resource.
*
* @deprecated in Emu Release
*/
@Deprecated
public class MplsLabelResourceAllocation implements ResourceAllocation {
private final MplsLabel mplsLabel;
@Override
public ResourceType type() {
return ResourceType.MPLS_LABEL;
}
/**
* Creates a new {@link MplsLabelResourceAllocation} with {@link MplsLabel}
* object.
*
* @param mplsLabel allocated MPLS Label
*/
public MplsLabelResourceAllocation(MplsLabel mplsLabel) {
this.mplsLabel = mplsLabel;
}
/**
* Returns the MPLS label resource.
*
* @return the MPLS label resource
*/
public MplsLabel mplsLabel() {
return mplsLabel;
}
@Override
public int hashCode() {
return Objects.hashCode(mplsLabel);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final MplsLabelResourceAllocation other = (MplsLabelResourceAllocation) obj;
return Objects.equals(this.mplsLabel, other.mplsLabel);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("mplsLabel", mplsLabel)
.toString();
}
}
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource.link;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Representation of a request for lambda resource.
*
* @deprecated in Emu Release
*/
@Deprecated
public class MplsLabelResourceRequest implements ResourceRequest {
private final MplsLabel mplsLabel;
/**
* Constructs a request specifying the given MPLS label.
*
* @param mplsLabel MPLS label to be requested
*/
@Beta
public MplsLabelResourceRequest(MplsLabel mplsLabel) {
this.mplsLabel = checkNotNull(mplsLabel);
}
/**
* Constructs a request asking an arbitrary available MPLS label.
*
* @deprecated in Emu Release
*/
@Deprecated
public MplsLabelResourceRequest() {
this.mplsLabel = null;
}
/**
* Returns the MPLS label this request expects.
*
* @return the MPLS label this request expects
*/
@Beta
public MplsLabel mplsLabel() {
return mplsLabel;
}
@Override
public ResourceType type() {
return ResourceType.MPLS_LABEL;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("mplsLabel", mplsLabel)
.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.resource;
import org.junit.Test;
import com.google.common.testing.EqualsTester;
import org.onosproject.net.resource.link.MplsLabel;
import org.onosproject.net.resource.link.MplsLabelResourceAllocation;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
* Unit tests for MPLS objects.
*/
public class MplsObjectsTest {
MplsLabel label1 = MplsLabel.valueOf(1);
MplsLabel label2 = MplsLabel.valueOf(2);
MplsLabel sameAsLabel1 = MplsLabel.valueOf(1);
MplsLabel sameAsLabel2 = MplsLabel.valueOf(2);
MplsLabel label3 = MplsLabel.valueOf(3);
/**
* Tests creation of MPLS label objects.
*/
@Test
public void checkLabelConstruction() {
assertThat(label1.label().toInt(), is(1));
}
/**
* Tests the operation of equals(), hashCode() and toString().
*/
@Test
public void testLabelEqualsOperation() {
new EqualsTester()
.addEqualityGroup(label1, sameAsLabel1)
.addEqualityGroup(label2, sameAsLabel2)
.addEqualityGroup(label3)
.testEquals();
}
MplsLabelResourceAllocation labelAllocation1 =
new MplsLabelResourceAllocation(label1);
MplsLabelResourceAllocation sameAsLabelAllocation1 =
new MplsLabelResourceAllocation(label1);
MplsLabelResourceAllocation labelAllocation2 =
new MplsLabelResourceAllocation(label2);
MplsLabelResourceAllocation sameAsLabelAllocation2 =
new MplsLabelResourceAllocation(label2);
MplsLabelResourceAllocation labelAllocation3 =
new MplsLabelResourceAllocation(label3);
/**
* Tests creation of MPLS label objects.
*/
@Test
public void checkLabelResourceAllocationConstruction() {
assertThat(labelAllocation1.mplsLabel().label().toInt(), is(1));
assertThat(labelAllocation1.type(), is(ResourceType.MPLS_LABEL));
}
/**
* Tests the operation of equals(), hashCode() and toString().
*/
@Test
public void testLabelResourceAllocationEqualsOperation() {
new EqualsTester()
.addEqualityGroup(labelAllocation1, sameAsLabelAllocation1)
.addEqualityGroup(labelAllocation2, sameAsLabelAllocation2)
.addEqualityGroup(labelAllocation3)
.testEquals();
}
}
......@@ -188,18 +188,6 @@ import org.onosproject.net.packet.DefaultOutboundPacket;
import org.onosproject.net.packet.DefaultPacketRequest;
import org.onosproject.net.packet.PacketPriority;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.resource.link.BandwidthResource;
import org.onosproject.net.resource.link.BandwidthResourceAllocation;
import org.onosproject.net.resource.link.BandwidthResourceRequest;
import org.onosproject.net.resource.link.DefaultLinkResourceAllocations;
import org.onosproject.net.resource.link.DefaultLinkResourceRequest;
import org.onosproject.net.resource.link.LambdaResource;
import org.onosproject.net.resource.link.LambdaResourceAllocation;
import org.onosproject.net.resource.link.LambdaResourceRequest;
import org.onosproject.net.resource.link.LinkResourceRequest;
import org.onosproject.net.resource.link.MplsLabel;
import org.onosproject.net.resource.link.MplsLabelResourceAllocation;
import org.onosproject.net.resource.link.MplsLabelResourceRequest;
import org.onosproject.security.Permission;
import org.onosproject.store.Timestamp;
import org.onosproject.store.primitives.MapUpdate;
......@@ -438,15 +426,6 @@ public final class KryoNamespaces {
OpticalConnectivityIntent.class,
OpticalPathIntent.class,
OpticalCircuitIntent.class,
LinkResourceRequest.class,
DefaultLinkResourceRequest.class,
BandwidthResourceRequest.class,
LambdaResourceRequest.class,
LambdaResource.class,
BandwidthResource.class,
DefaultLinkResourceAllocations.class,
BandwidthResourceAllocation.class,
LambdaResourceAllocation.class,
DiscreteResource.class,
ContinuousResource.class,
DiscreteResourceId.class,
......@@ -521,9 +500,6 @@ public final class KryoNamespaces {
.register(
MplsIntent.class,
MplsPathIntent.class,
MplsLabelResourceAllocation.class,
MplsLabelResourceRequest.class,
MplsLabel.class,
org.onlab.packet.MplsLabel.class,
org.onlab.packet.MPLS.class
)
......
......@@ -45,7 +45,6 @@ import org.onosproject.net.DeviceId;
import org.onosproject.net.GridType;
import org.onosproject.net.HostLocation;
import org.onosproject.net.Link;
import org.onosproject.net.Link.Type;
import org.onosproject.net.LinkKey;
import org.onosproject.net.OchPort;
import org.onosproject.net.OchSignal;
......@@ -65,14 +64,6 @@ import org.onosproject.net.flow.FlowRuleBatchEntry;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.newresource.Resources;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.resource.link.BandwidthResource;
import org.onosproject.net.resource.link.BandwidthResourceAllocation;
import org.onosproject.net.resource.link.DefaultLinkResourceAllocations;
import org.onosproject.net.resource.link.DefaultLinkResourceRequest;
import org.onosproject.net.resource.link.LambdaResource;
import org.onosproject.net.resource.link.LambdaResourceAllocation;
import org.onosproject.net.resource.link.LinkResourceRequest;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.intent.constraint.AnnotationConstraint;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
import org.onosproject.net.intent.constraint.LatencyConstraint;
......@@ -92,9 +83,6 @@ import org.onlab.util.KryoNamespace;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.time.Duration;
import static java.util.Arrays.asList;
......@@ -367,31 +355,6 @@ public class KryoSerializerTest {
}
@Test
public void testDefaultLinkResourceRequest() {
testSerializable(DefaultLinkResourceRequest.builder(IntentId.valueOf(2501), ImmutableList.of())
.addLambdaRequest()
.addBandwidthRequest(32.195)
.build()
);
}
@Test
public void testDefaultLinkResourceAllocations() {
LinkResourceRequest request = DefaultLinkResourceRequest
.builder(IntentId.valueOf(2501), ImmutableList.of())
.addLambdaRequest()
.addBandwidthRequest(32.195)
.build();
Map<Link, Set<ResourceAllocation>> allocations = new HashMap<>();
allocations.put(DefaultLink.builder()
.providerId(PID)
.src(CP1).dst(CP2).type(Type.DIRECT).build(),
ImmutableSet.of(new BandwidthResourceAllocation(new BandwidthResource(Bandwidth.bps(10.0))),
new LambdaResourceAllocation(LambdaResource.valueOf(1))));
testSerializable(new DefaultLinkResourceAllocations(request, allocations));
}
@Test
public void testResource() {
testSerializedEquals(Resources.discrete(DID1, P1, VLAN1).resource());
}
......