diff options
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/core')
16 files changed, 0 insertions, 1094 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/Application.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/Application.java deleted file mode 100644 index ea2eab9b..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/Application.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.core; - -import org.onosproject.security.Permission; - -import java.net.URI; -import java.util.List; -import java.util.Optional; -import java.util.Set; - -/** - * Abstraction of a network control/management application. - */ -public interface Application { - - /** - * Returns the application name id. - * - * @return application identifier - */ - ApplicationId id(); - - /** - * Returns the application version. - * - * @return application version - */ - Version version(); - - /** - * Returns description of the application. - * - * @return application description text - */ - String description(); - - /** - * Returns the name of the application origin, group or company. - * - * @return application origin - */ - String origin(); - - /** - * Returns the role of the application. - * - * @return application role - */ - ApplicationRole role(); - - /** - * Returns the permissions requested by the application. - * - * @return requested permissions - */ - Set<Permission> permissions(); - - /** - * Returns the feature repository URI. Null value signifies that the - * application did not provide its own features repository. - * - * @return optional feature repo URL - */ - Optional<URI> featuresRepo(); - - /** - * Returns the list of features comprising the application. At least one - * feature must be given. - * - * @return application features - */ - List<String> features(); - - /** - * Returns list of required application names. - * - * @return list of application names - */ - List<String> requiredApps(); -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/ApplicationId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/ApplicationId.java deleted file mode 100644 index 25bc8ce7..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/ApplicationId.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.core; - - -/** - * Application identifier. - */ -public interface ApplicationId { - - /** - * Returns the application id. - * @return a short value - */ - short id(); - - /** - * Returns the applications supplied identifier. - * @return a string identifier - */ - String name(); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/ApplicationIdStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/ApplicationIdStore.java deleted file mode 100644 index f857fbdc..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/ApplicationIdStore.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.core; -// FIXME: Move to org.onosproject.app package - -import java.util.Set; - -/** - * Manages application IDs. - */ -public interface ApplicationIdStore { - - /** - * Returns the set of currently registered application identifiers. - * - * @return set of application ids - */ - Set<ApplicationId> getAppIds(); - - /** - * Returns an existing application id from a given id. - * - * @param id the short value of the id - * @return an application id; null if no such app registered - */ - ApplicationId getAppId(Short id); - - /** - * Returns registered application id from the given name. - * - * @param name application name - * @return an application id; null if no such app registered - */ - ApplicationId getAppId(String name); - - /** - * Registers a new application by its name, which is expected - * to follow the reverse DNS convention, e.g. - * {@code org.flying.circus.app} - * - * @param identifier string identifier - * @return the application id - */ - ApplicationId registerApplication(String identifier); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/ApplicationRole.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/ApplicationRole.java deleted file mode 100644 index 5fcb80ba..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/ApplicationRole.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.core; - -public enum ApplicationRole { - /** - * Indicates that an application has an ADMIN role. - */ - ADMIN, - - /** - * Indicates that an application has a USER role. - */ - USER, - - /** - * Indicates that an application role has not been specified. - */ - UNSPECIFIED, - - /** - * More useful roles may be defined. - */ -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java deleted file mode 100644 index 0825a6d1..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.core; - -import org.onosproject.net.provider.ProviderId; - -import java.util.Set; - -/** - * Service for interacting with the core system of the controller. - */ -public interface CoreService { - - /** - * Name of the core "application". - */ - String CORE_APP_NAME = "org.onosproject.core"; - - /** - * Identifier of the core "provider". - */ - ProviderId CORE_PROVIDER_ID = new ProviderId("core", CORE_APP_NAME); - - /** - * Returns the product version. - * - * @return product version - */ - Version version(); - - /** - * Returns the set of currently registered application identifiers. - * - * @return set of application ids - */ - Set<ApplicationId> getAppIds(); - - /** - * Returns an existing application id from a given id. - * - * @param id the short value of the id - * @return an application id - */ - ApplicationId getAppId(Short id); - - /** - * Returns an existing application id from a given id. - * - * @param name the name portion of the ID to look up - * @return an application id - */ - ApplicationId getAppId(String name); - - /** - * Registers a new application by its name, which is expected - * to follow the reverse DNS convention, e.g. - * {@code org.flying.circus.app} - * - * @param name string identifier - * @return the application id - */ - ApplicationId registerApplication(String name); - - /** - * Registers a new application by its name, which is expected - * to follow the reverse DNS convention, e.g. - * {@code org.flying.circus.app}, along with its pre-deactivation hook. - * - * @param name string identifier - * @param preDeactivate pre-deactivation hook - * @return the application id - */ - ApplicationId registerApplication(String name, Runnable preDeactivate); - - /** - * Returns an id generator for a given topic. - * - * @param topic topic identified - * @return the id generator - */ - IdGenerator getIdGenerator(String topic); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplication.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplication.java deleted file mode 100644 index c3515638..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplication.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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.core; - -import org.onosproject.security.Permission; - -import java.net.URI; -import java.util.Set; -import java.util.Optional; -import java.util.List; -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Default implementation of network control/management application descriptor. - */ -public class DefaultApplication implements Application { - - private final ApplicationId appId; - private final Version version; - private final String description; - private final String origin; - private final ApplicationRole role; - private final Set<Permission> permissions; - private final Optional<URI> featuresRepo; - private final List<String> features; - private final List<String> requiredApps; - - /** - * Creates a new application descriptor using the supplied data. - * - * @param appId application identifier - * @param version application version - * @param description application description - * @param origin origin company - * @param role application role - * @param permissions requested permissions - * @param featuresRepo optional features repo URI - * @param features application features - * @param requiredApps list of required application names - */ - public DefaultApplication(ApplicationId appId, Version version, - String description, String origin, - ApplicationRole role, Set<Permission> permissions, - Optional<URI> featuresRepo, List<String> features, - List<String> requiredApps) { - this.appId = checkNotNull(appId, "ID cannot be null"); - this.version = checkNotNull(version, "Version cannot be null"); - this.description = checkNotNull(description, "Description cannot be null"); - this.origin = checkNotNull(origin, "Origin cannot be null"); - this.role = checkNotNull(role, "Role cannot be null"); - this.permissions = checkNotNull(permissions, "Permissions cannot be null"); - this.featuresRepo = checkNotNull(featuresRepo, "Features repo cannot be null"); - this.features = checkNotNull(features, "Features cannot be null"); - this.requiredApps = checkNotNull(requiredApps, "Required apps cannot be null"); - checkArgument(!features.isEmpty(), "There must be at least one feature"); - } - - @Override - public ApplicationId id() { - return appId; - } - - @Override - public Version version() { - return version; - } - - @Override - public String description() { - return description; - } - - @Override - public String origin() { - return origin; - } - - @Override - public ApplicationRole role() { - return role; - } - - @Override - public Set<Permission> permissions() { - return permissions; - } - - @Override - public Optional<URI> featuresRepo() { - return featuresRepo; - } - - @Override - public List<String> features() { - return features; - } - - @Override - public List<String> requiredApps() { - return requiredApps; - } - - @Override - public int hashCode() { - return Objects.hash(appId, version, description, origin, role, permissions, - featuresRepo, features, requiredApps); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - final DefaultApplication other = (DefaultApplication) obj; - return Objects.equals(this.appId, other.appId) && - Objects.equals(this.version, other.version) && - Objects.equals(this.description, other.description) && - Objects.equals(this.origin, other.origin) && - Objects.equals(this.role, other.role) && - Objects.equals(this.permissions, other.permissions) && - Objects.equals(this.featuresRepo, other.featuresRepo) && - Objects.equals(this.features, other.features) && - Objects.equals(this.requiredApps, other.requiredApps); - } - - @Override - public String toString() { - return toStringHelper(this) - .add("appId", appId) - .add("version", version) - .add("description", description) - .add("origin", origin) - .add("role", role) - .add("permissions", permissions) - .add("featuresRepo", featuresRepo) - .add("features", features) - .add("requiredApps", requiredApps) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java deleted file mode 100644 index aedfb0d3..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.core; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; -import static com.google.common.base.Preconditions.checkArgument; - -/** - * Application identifier. - */ -public class DefaultApplicationId implements ApplicationId { - - private final short id; - private final String name; - - /** - * Creates a new application ID. - * - * @param id application identifier - * @param name application name - */ - public DefaultApplicationId(int id, String name) { - checkArgument(0 <= id && id <= Short.MAX_VALUE, "id is outside range"); - this.id = (short) id; - this.name = name; - } - - // Constructor for serializers. - private DefaultApplicationId() { - this.id = 0; - this.name = null; - } - - @Override - public short id() { - return id; - } - - @Override - public String name() { - return name; - } - - @Override - public int hashCode() { - return Short.hashCode(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof DefaultApplicationId) { - DefaultApplicationId other = (DefaultApplicationId) obj; - return Objects.equals(this.id, other.id); - } - return false; - } - - @Override - public String toString() { - return toStringHelper(this).add("id", id).add("name", name).toString(); - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java deleted file mode 100644 index 243e5216..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.core; - -import com.google.common.base.MoreObjects; - -import java.util.Objects; - -/** - * Default implementation of {@link GroupId}. - */ -public class DefaultGroupId implements GroupId { - - private final int id; - - public DefaultGroupId(int id) { - this.id = id; - } - - // Constructor for serialization - private DefaultGroupId() { - this.id = 0; - } - - @Override - public int id() { - return this.id; - } - - @Override - public int hashCode() { - return id; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof DefaultGroupId)) { - return false; - } - final DefaultGroupId other = (DefaultGroupId) obj; - return Objects.equals(this.id, other.id); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("id", id) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/GroupId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/GroupId.java deleted file mode 100644 index 739fc7ff..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/GroupId.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.core; - -/** - * Group identifier. - */ -public interface GroupId { - - /** - * Returns a group ID as an integer value. - * The method is not intended for use by application developers. - * Return data type may change in the future release. - * - * @return a group ID as integer value - */ - int id(); -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/IdBlock.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/IdBlock.java deleted file mode 100644 index f4088603..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/IdBlock.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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.core; - -import com.google.common.base.MoreObjects; - -import java.util.concurrent.atomic.AtomicLong; - -import static com.google.common.base.Preconditions.checkArgument; - -/** - * A class representing an ID space. - */ -public final class IdBlock { - private final long start; - private final long size; - - private final AtomicLong currentId; - - /** - * Constructs a new ID block with the specified size and initial value. - * - * @param start initial value of the block - * @param size size of the block - * @throws IllegalArgumentException if the size is less than or equal to 0 - */ - public IdBlock(long start, long size) { - checkArgument(size > 0, "size should be more than 0, but %s", size); - - this.start = start; - this.size = size; - - this.currentId = new AtomicLong(start); - } - - /** - * Returns the initial value. - * - * @return initial value - */ - private long getStart() { - return start; - } - - /** - * Returns the last value. - * - * @return last value - */ - private long getEnd() { - return start + size - 1; - } - - /** - * Returns the block size. - * - * @return block size - */ - public long getSize() { - return size; - } - - /** - * Returns the next ID in the block. - * - * @return next ID - * @throws UnavailableIdException if there is no available ID in the block. - */ - public long getNextId() { - final long id = currentId.getAndIncrement(); - if (id > getEnd()) { - throw new UnavailableIdException(String.format( - "used all IDs in allocated space (size: %d, end: %d, current: %d)", - size, getEnd(), id - )); - } - - return id; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("start", start) - .add("size", size) - .add("currentId", currentId) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/IdBlockStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/IdBlockStore.java deleted file mode 100644 index 8ed58ae7..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/IdBlockStore.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.core; - -/** - * Manages id blocks. - */ -public interface IdBlockStore { - - /** - * Returns a topic-unique block of ids. - * - * @param topic topic name - * @return id block - */ - IdBlock getIdBlock(String topic); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/IdGenerator.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/IdGenerator.java deleted file mode 100644 index 149c834b..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/IdGenerator.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.core; - -/** - * A generalized interface for ID generation - * - * {@link #getNewId()} generates a globally unique ID instance on - * each invocation. - */ -public interface IdGenerator { - /** - * Returns a globally unique ID instance. - * - * @return globally unique ID instance - */ - long getNewId(); -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java deleted file mode 100644 index 8de05439..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.core; - -import org.onlab.metrics.MetricsComponent; -import org.onlab.metrics.MetricsFeature; -import org.onlab.metrics.MetricsService; - -import com.codahale.metrics.Timer; - -/** - * Collection of utility methods used for providing Metrics. - */ -public interface MetricsHelper { - - /** - * Returns MetricService instance. - * - * @return MetricService instance - */ - MetricsService metricsService(); - - - /** - * Creates a Timer instance with given name. - * - * @param component component name - * @param feature feature name - * @param name timer name - * @return Timer instance - */ - default Timer createTimer(String component, String feature, String name) { - final MetricsService metricsService = metricsService(); - if (metricsService != null) { - MetricsComponent c = metricsService.registerComponent(component); - MetricsFeature f = c.registerFeature(feature); - return metricsService.createTimer(c, f, name); - } - return null; - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/UnavailableIdException.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/UnavailableIdException.java deleted file mode 100644 index 2e4af264..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/UnavailableIdException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.core; - -/** - * Represents that there is no available IDs. - */ -public class UnavailableIdException extends RuntimeException { - - private static final long serialVersionUID = -2287403908433720122L; - - /** - * Constructs an exception with no message and no underlying cause. - */ - public UnavailableIdException() { - } - - /** - * Constructs an exception with the specified message. - * - * @param message the message describing the specific nature of the error - */ - public UnavailableIdException(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 UnavailableIdException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java deleted file mode 100644 index 06e9e206..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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.core; - -import java.util.Objects; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Strings.isNullOrEmpty; -import static java.lang.Integer.parseInt; - -/** - * Representation of the product version. - */ -public final class Version { - - public static final String FORMAT_MINIMAL = "%d.%d"; - public static final String FORMAT_SHORT = "%d.%d.%s"; - public static final String FORMAT_LONG = "%d.%d.%s.%s"; - - private static final String NEGATIVE = "Version segment cannot be negative"; - public static final String TOO_SHORT = "Version must have at least major and minor numbers"; - - private final int major; - private final int minor; - private final String patch; - private final String build; - - private final String format; - - // Creates a new version descriptor - private Version(int major, int minor, String patch, String build) { - this.major = major; - this.minor = minor; - this.patch = patch; - this.build = build; - this.format = - isNullOrEmpty(patch) ? - String.format(FORMAT_MINIMAL, major, minor) : - (isNullOrEmpty(build) ? - String.format(FORMAT_SHORT, major, minor, patch) : - String.format(FORMAT_LONG, major, minor, patch, build)); - } - - - /** - * Creates a new version from the specified constituent numbers. - * - * @param major major version number - * @param minor minor version number - * @param patch version patch segment - * @param build optional build string - * @return version descriptor - */ - public static Version version(int major, int minor, String patch, String build) { - checkArgument(major >= 0, NEGATIVE); - checkArgument(minor >= 0, NEGATIVE); - return new Version(major, minor, patch, build); - } - - /** - * Creates a new version by parsing the specified string. - * - * @param string version string - * @return version descriptor - */ - public static Version version(String string) { - String[] fields = string.split("[.-]"); - checkArgument(fields.length >= 2, TOO_SHORT); - return new Version(parseInt(fields[0]), parseInt(fields[1]), - fields.length >= 3 ? fields[2] : null, - fields.length >= 4 ? fields[3] : null); - } - - /** - * Returns the major version number. - * - * @return major version number - */ - public int major() { - return major; - } - - /** - * Returns the minor version number. - * - * @return minor version number - */ - public int minor() { - return minor; - } - - /** - * Returns the version patch segment. - * - * @return patch number - */ - public String patch() { - return patch; - } - - /** - * Returns the version build string. - * - * @return build string - */ - public String build() { - return build; - } - - @Override - public String toString() { - return format; - } - - @Override - public int hashCode() { - return format.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof Version) { - final Version other = (Version) obj; - return Objects.equals(this.format, other.format); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/package-info.java deleted file mode 100644 index 3766d49f..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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. - */ - -/** - * ONOS Core API definitions. - */ -package org.onosproject.core; |