diff options
author | CNlucius <lukai1@huawei.com> | 2016-09-13 11:40:12 +0800 |
---|---|---|
committer | CNlucius <lukai1@huawei.com> | 2016-09-13 11:41:53 +0800 |
commit | b731e2f1dd0972409b136aebc7b463dd72c9cfad (patch) | |
tree | 5107d7d80c19ad8076c2c97c2b5ef8d1cf3ab903 /framework/src/onos/core/net/src/main/java/org/onosproject/core | |
parent | ee93993458266114c29271a481ef9ce7ce621b2a (diff) |
ONOSFW-171
O/S-SFC-ONOS scenario documentation
Change-Id: I51ae1cf736ea24ab6680f8edca1b2bf5dd598365
Signed-off-by: CNlucius <lukai1@huawei.com>
Diffstat (limited to 'framework/src/onos/core/net/src/main/java/org/onosproject/core')
6 files changed, 0 insertions, 416 deletions
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/BlockAllocatorBasedIdGenerator.java b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/BlockAllocatorBasedIdGenerator.java deleted file mode 100644 index 267cd713..00000000 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/BlockAllocatorBasedIdGenerator.java +++ /dev/null @@ -1,65 +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.impl; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.onosproject.core.IdBlock; -import org.onosproject.core.IdGenerator; -import org.onosproject.core.UnavailableIdException; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Base class of {@link IdGenerator} implementations which use {@link IdBlockAllocator} as - * backend. - */ -public class BlockAllocatorBasedIdGenerator implements IdGenerator { - protected final IdBlockAllocator allocator; - protected IdBlock idBlock; - protected AtomicBoolean initialized; - - - /** - * Constructs an ID generator which use {@link IdBlockAllocator} as backend. - * - * @param allocator the ID block allocator to use - */ - protected BlockAllocatorBasedIdGenerator(IdBlockAllocator allocator) { - this.allocator = checkNotNull(allocator, "allocator cannot be null"); - this.initialized = new AtomicBoolean(false); - } - - @Override - public long getNewId() { - try { - if (!initialized.get()) { - synchronized (allocator) { - if (!initialized.get()) { - idBlock = allocator.allocateUniqueIdBlock(); - initialized.set(true); - } - } - } - return idBlock.getNextId(); - } catch (UnavailableIdException e) { - synchronized (allocator) { - idBlock = allocator.allocateUniqueIdBlock(); - } - return idBlock.getNextId(); - } - } -} diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java deleted file mode 100644 index 4a702ef0..00000000 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java +++ /dev/null @@ -1,206 +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.impl; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Modified; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.apache.felix.scr.annotations.Service; -import org.onlab.util.SharedExecutors; -import org.onosproject.app.ApplicationService; -import org.onosproject.cfg.ComponentConfigService; -import org.onosproject.core.ApplicationId; -import org.onosproject.core.ApplicationIdStore; -import org.onosproject.core.CoreService; -import org.onosproject.core.IdBlockStore; -import org.onosproject.core.IdGenerator; -import org.onosproject.core.Version; -import org.onosproject.event.EventDeliveryService; -import org.osgi.service.component.ComponentContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Dictionary; -import java.util.List; -import java.util.Set; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Strings.isNullOrEmpty; -import static org.onosproject.security.AppGuard.checkPermission; -import static org.onosproject.security.AppPermission.Type.APP_READ; - - - -/** - * Core service implementation. - */ -@Component(immediate = true) -@Service -public class CoreManager implements CoreService { - - private final Logger log = LoggerFactory.getLogger(getClass()); - - private static final File VERSION_FILE = new File("../VERSION"); - private static Version version = Version.version("1.4.0-rc1"); - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected ApplicationIdStore applicationIdStore; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected IdBlockStore idBlockStore; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected ApplicationService appService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected ComponentConfigService cfgService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected EventDeliveryService eventDeliveryService; - - private static final int DEFAULT_POOL_SIZE = 30; - @Property(name = "sharedThreadPoolSize", intValue = DEFAULT_POOL_SIZE, - label = "Configure shared pool maximum size ") - private int sharedThreadPoolSize = DEFAULT_POOL_SIZE; - - private static final int DEFAULT_EVENT_TIME = 2000; - @Property(name = "maxEventTimeLimit", intValue = DEFAULT_EVENT_TIME, - label = "Maximum number of millis an event sink has to process an event") - private int maxEventTimeLimit = DEFAULT_EVENT_TIME; - - @Activate - public void activate() { - registerApplication(CORE_APP_NAME); - cfgService.registerProperties(getClass()); - try { - Path path = Paths.get(VERSION_FILE.getPath()); - List<String> versionLines = Files.readAllLines(path); - if (versionLines != null && !versionLines.isEmpty()) { - version = Version.version(versionLines.get(0)); - } - } catch (IOException e) { - // version file not found, using default - log.trace("Version file not found", e); - } - } - - @Deactivate - public void deactivate() { - cfgService.unregisterProperties(getClass(), false); - SharedExecutors.shutdown(); - } - - @Override - public Version version() { - checkPermission(APP_READ); - return version; - } - - @Override - public Set<ApplicationId> getAppIds() { - checkPermission(APP_READ); - return applicationIdStore.getAppIds(); - } - - @Override - public ApplicationId getAppId(Short id) { - checkPermission(APP_READ); - return applicationIdStore.getAppId(id); - } - - @Override - public ApplicationId getAppId(String name) { - checkPermission(APP_READ); - return applicationIdStore.getAppId(name); - } - - - @Override - public ApplicationId registerApplication(String name) { - checkNotNull(name, "Application ID cannot be null"); - return applicationIdStore.registerApplication(name); - } - - @Override - public ApplicationId registerApplication(String name, Runnable preDeactivate) { - ApplicationId id = registerApplication(name); - appService.registerDeactivateHook(id, preDeactivate); - return id; - } - - @Override - public IdGenerator getIdGenerator(String topic) { - IdBlockAllocator allocator = new StoreBasedIdBlockAllocator(topic, idBlockStore); - return new BlockAllocatorBasedIdGenerator(allocator); - } - - - @Modified - public void modified(ComponentContext context) { - Dictionary<?, ?> properties = context.getProperties(); - Integer poolSize = getIntegerProperty(properties, "sharedThreadPoolSize"); - - if (poolSize != null && poolSize > 1) { - sharedThreadPoolSize = poolSize; - SharedExecutors.setPoolSize(sharedThreadPoolSize); - } else if (poolSize != null) { - log.warn("sharedThreadPoolSize must be greater than 1"); - } - - Integer timeLimit = getIntegerProperty(properties, "maxEventTimeLimit"); - if (timeLimit != null && timeLimit > 1) { - maxEventTimeLimit = timeLimit; - eventDeliveryService.setDispatchTimeLimit(maxEventTimeLimit); - } else if (timeLimit != null) { - log.warn("maxEventTimeLimit must be greater than 1"); - } - - log.info("Settings: sharedThreadPoolSize={}, maxEventTimeLimit={}", - sharedThreadPoolSize, maxEventTimeLimit); - } - - - /** - * Get Integer property from the propertyName - * Return null if propertyName is not found. - * - * @param properties properties to be looked up - * @param propertyName the name of the property to look up - * @return value when the propertyName is defined or return null - */ - private static Integer getIntegerProperty(Dictionary<?, ?> properties, - String propertyName) { - Integer value; - try { - String s = (String) properties.get(propertyName); - value = isNullOrEmpty(s) ? null : Integer.parseInt(s.trim()); - } catch (NumberFormatException | ClassCastException e) { - value = null; - } - return value; - } - - -} diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/IdBlockAllocator.java b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/IdBlockAllocator.java deleted file mode 100644 index ba8594f2..00000000 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/IdBlockAllocator.java +++ /dev/null @@ -1,38 +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.impl; - -import org.onosproject.core.IdBlock; - -/** - * An interface that gives unique ID spaces. - */ -public interface IdBlockAllocator { - /** - * Allocates a unique Id Block. - * - * @return Id Block. - */ - IdBlock allocateUniqueIdBlock(); - - /** - * Allocates next unique id and retrieve a new range of ids if needed. - * - * @param range range to use for the identifier - * @return Id Block. - */ - IdBlock allocateUniqueIdBlock(long range); -} diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/MetricsManagerComponent.java b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/MetricsManagerComponent.java deleted file mode 100644 index 5a3f08df..00000000 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/MetricsManagerComponent.java +++ /dev/null @@ -1,41 +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.impl; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Service; - -import org.onlab.metrics.MetricsManager; - -/** - * Metrics service implementation. - */ -@Component(immediate = true) -@Service -public class MetricsManagerComponent extends MetricsManager { - - @Activate - protected void activate() { - super.clear(); - } - - @Deactivate - protected void deactivate() { - super.clear(); - } -} diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/StoreBasedIdBlockAllocator.java b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/StoreBasedIdBlockAllocator.java deleted file mode 100644 index c28de73d..00000000 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/StoreBasedIdBlockAllocator.java +++ /dev/null @@ -1,46 +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.impl; - -import org.onosproject.core.IdBlock; -import org.onosproject.core.IdBlockStore; - -public class StoreBasedIdBlockAllocator implements IdBlockAllocator { - private final IdBlockStore store; - private final String topic; - - public StoreBasedIdBlockAllocator(String topic, IdBlockStore store) { - this.topic = topic; - this.store = store; - } - - /** - * Returns a block of IDs which are unique and unused. - * Range of IDs is fixed size and is assigned incrementally as this method - * called. - * - * @return an IdBlock containing a set of unique IDs - */ - @Override - public synchronized IdBlock allocateUniqueIdBlock() { - return store.getIdBlock(topic); - } - - @Override - public IdBlock allocateUniqueIdBlock(long range) { - throw new UnsupportedOperationException("Not supported yet"); - } -} diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/package-info.java b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/package-info.java deleted file mode 100644 index f8c3e672..00000000 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/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. - */ - -/** - * Miscellaneous core system implementations. - */ -package org.onosproject.core.impl; |