+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.binding.api.rpc;
-
-import java.util.Set;
-
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-/**
- * RpcRouter is responsible for selecting RpcService based on provided routing
- * context identifier {@link RpcRoutingTable#getContextIdentifier()} and path in
- * overall data tree (@link {@link InstanceIdentifier}.
- *
- *
- * @author Tony Tkacik <ttkacik@cisco.com>
- *
- * @param <T>
- * Type of RpcService for which router provides routing information
- * and route selection.
- */
-public interface RpcRouter<T extends RpcService> extends //
- RouteChangePublisher<Class<? extends BaseIdentity>, InstanceIdentifier<?>> {
-
- /**
- * Returns a type of RpcService which is served by this instance of router.
- *
- * @return type of RpcService which is served by this instance of router.
- */
- Class<T> getServiceType();
-
-
- /**
- * Returns a instance of T which is associated with this router instance
- * and routes messages based on routing tables.
- *
- * @return type of RpcService which is served by this instance of router.
- */
- T getInvocationProxy();
-
- /**
- * Returns a routing table for particular route context
- *
- * @param routeContext
- * @return Routing Table for particular route context.
- */
- <C extends BaseIdentity> RpcRoutingTable<C, T> getRoutingTable(Class<C> routeContext);
-
- /**
- * Returns an instance of RpcService which is responsible for processing
- * particular path.
- *
- * @param context
- * Rpc Routing Context
- * @param path
- * Instance Identifier which is used as a selector of instance.
- * @return instance of RpcService which is responsible for processing
- * particular path.
- */
- T getService(Class<? extends BaseIdentity> context, InstanceIdentifier<?> path);
-
- /**
- * Returns a default fallback instance of RpcService which is responsible
- * for handling all unknown imports.
- *
- * @return default instance responsible for processing RPCs.
- */
- T getDefaultService();
-
- Set<Class<? extends BaseIdentity>> getContexts();
-
- RoutedRpcRegistration<T> addRoutedRpcImplementation(T service);
-
- RpcRegistration<T> registerDefaultService(T service);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.binding.api.rpc;
-
-import java.util.Map;
-
-import org.opendaylight.controller.md.sal.common.api.routing.MutableRoutingTable;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-public interface RpcRoutingTable<C extends BaseIdentity, S extends RpcService> extends
- MutableRoutingTable<Class<? extends C>, InstanceIdentifier<?>, S> {
-
- Class<C> getIdentifier();
-
- /**
- * Updates route for particular path to specified instance of
- * {@link RpcService}.
- *
- * @param path
- * Path for which RpcService routing is to be updated
- * @param service
- * Instance of RpcService which is responsible for processing Rpc
- * Requests.
- */
- void updateRoute(InstanceIdentifier<?> path, S service);
-
- /**
- * Deletes a route for particular path
- *
- * @param path
- * Path for which
- */
- void removeRoute(InstanceIdentifier<?> path);
-
- /**
- *
- */
- S getRoute(InstanceIdentifier<?> nodeInstance);
-
- /**
- *
- * @return
- */
- Map<InstanceIdentifier<?>, S> getRoutes();
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.sal.common.api.routing;
-
-import org.opendaylight.yangtools.concepts.Mutable;
-import org.opendaylight.yangtools.concepts.Path;
-
-public interface MutableRoutingTable<C, P extends Path<P>, T> extends RoutingTable<C,P,T>, Mutable {
-
- void setDefaultRoute(T target);
- void updateRoute(P path,T target);
- void removeRoute(P path);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.sal.common.api.routing;
-
-import org.opendaylight.yangtools.concepts.Immutable;
-
-public interface Route<C,P> extends Immutable {
-
- C getType();
-
- P getPath();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.sal.common.api.routing;
-
-import java.util.Map;
-import java.util.Set;
-
-public interface Router<C,P,D> extends //
- RouteChangePublisher<C, P> {
-
- Map<C, Set<P>> getAnnouncedPaths();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.sal.common.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Collections;
-import java.util.EventListener;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-public class ListenerRegistry<T extends EventListener> {
-
- final Set<ListenerRegistration<T>> listeners;
- final Set<ListenerRegistration<T>> unmodifiableView;
-
- public ListenerRegistry() {
- listeners = new HashSet<>();
- unmodifiableView = Collections.unmodifiableSet(listeners);
- }
-
- public Iterable<ListenerRegistration<T>> getListeners() {
- return unmodifiableView;
- }
-
-
- public ListenerRegistration<T> register(T listener) {
- checkNotNull(listener, "Listener should not be null.");
- ListenerRegistrationImpl<T> ret = new ListenerRegistrationImpl<T>(listener);
- listeners.add(ret);
- return ret;
- }
-
-
- @SuppressWarnings("rawtypes")
- private void remove(ListenerRegistrationImpl registration) {
- listeners.remove(registration);
- }
-
- private class ListenerRegistrationImpl<P extends EventListener> //
- extends AbstractObjectRegistration<P> //
- implements ListenerRegistration<P> {
-
- public ListenerRegistrationImpl(P instance) {
- super(instance);
- }
-
- @Override
- protected void removeRegistration() {
- ListenerRegistry.this.remove(this);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.sal.common.impl.routing;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChange;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
-public class RoutingUtils {
-
- public static <C,P> RouteChange<C,P> removalChange(C context,P path) {
- final ImmutableMap<C, Set<P>> announcements = ImmutableMap.<C,Set<P>>of();
- final ImmutableMap<C, Set<P>> removals = ImmutableMap.<C,Set<P>>of(context, ImmutableSet.of(path));
- return new RouteChangeImpl<C,P>(announcements, removals);
- }
-
- public static <C,P> RouteChange<C,P> announcementChange(C context,P path) {
- final ImmutableMap<C, Set<P>> announcements = ImmutableMap.<C,Set<P>>of(context, ImmutableSet.of(path));
- final ImmutableMap<C, Set<P>> removals = ImmutableMap.<C,Set<P>>of();
- return new RouteChangeImpl<C,P>(announcements, removals);
- }
-
-
- public static <C,P> RouteChange<C,P> change(Map<C, Set<P>> announcements,
- Map<C, Set<P>> removals) {
- final ImmutableMap<C, Set<P>> immutableAnnouncements = ImmutableMap.<C,Set<P>>copyOf(announcements);
- final ImmutableMap<C, Set<P>> immutableRemovals = ImmutableMap.<C,Set<P>>copyOf(removals);
- return new RouteChangeImpl<C,P>(immutableAnnouncements, immutableRemovals);
- }
-
-
- private static class RouteChangeImpl<C,P> implements RouteChange<C, P> {
- private final Map<C, Set<P>> removal;
- private final Map<C, Set<P>> announcement;
-
- public RouteChangeImpl(ImmutableMap<C, Set<P>> announcement, ImmutableMap<C, Set<P>> removal) {
- super();
- this.removal = removal;
- this.announcement = announcement;
- }
-
- @Override
- public Map<C, Set<P>> getAnnouncements() {
- return announcement;
- }
-
- @Override
- public Map<C, Set<P>> getRemovals() {
- return removal;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((announcement == null) ? 0 : announcement.hashCode());
- result = prime * result + ((removal == null) ? 0 : removal.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- RouteChangeImpl<?, ?> other = (RouteChangeImpl<?, ?>) obj;
- if (announcement == null) {
- if (other.announcement != null) {
- return false;
- }
- } else if (!announcement.equals(other.announcement)) {
- return false;
- }
- if (removal == null) {
- if (other.removal != null) {
- return false;
- }
- } else if (!removal.equals(other.removal)) {
- return false;
- }
- return true;
- }
- }
-
-
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.sal.common.impl.util;
-
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
-
-import org.opendaylight.yangtools.concepts.Delegator;
-
-import com.google.common.base.Preconditions;
-
-public class AbstractLockableDelegator<T> implements Delegator<T> {
-
- private final ReentrantReadWriteLock delegateLock = new ReentrantReadWriteLock();
- private final ReadLock delegateReadLock = delegateLock.readLock();
- private final WriteLock delegateWriteLock = delegateLock.writeLock();
-
-
- protected Lock getDelegateReadLock() {
- return delegateReadLock;
- }
-
- private T delegate;
-
- public AbstractLockableDelegator() {
- // NOOP
- }
-
- public AbstractLockableDelegator(T initialDelegate) {
- delegate = initialDelegate;
- }
-
- @Override
- public T getDelegate() {
- try {
- delegateReadLock.lock();
- return delegate;
- } finally {
- delegateReadLock.unlock();
- }
- }
-
- public T retrieveDelegate() {
- try {
- delegateReadLock.lock();
- Preconditions.checkState(delegate != null,"Delegate is null");
- return delegate;
- } finally {
- delegateReadLock.unlock();
- }
- }
-
- /**
- *
- * @param newDelegate
- * @return oldDelegate
- */
- public final T changeDelegate(T newDelegate) {
- try {
- delegateWriteLock.lock();
- T oldDelegate = delegate;
- delegate = newDelegate;
- onDelegateChanged(oldDelegate, newDelegate);
- return oldDelegate;
- } finally {
- delegateWriteLock.unlock();
- }
- }
-
-
- protected void onDelegateChanged(T oldDelegate, T newDelegate) {
- // NOOP in abstract calss;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.common.util;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-/**
- * @deprecated Use {@link com.google.common.util.concurrent.Futures} instead.
- */
-@Deprecated
-public class Futures {
-
- private Futures() {
- }
-
- public static <T> Future<T> immediateFuture(T result) {
- return new ImmediateFuture<T>(result);
- }
-
- private static class ImmediateFuture<T> implements Future<T> {
-
- private final T result;
-
- public ImmediateFuture(T result) {
- this.result = result;
- }
-
- @Override
- public boolean cancel(boolean mayInterruptIfRunning) {
- return false;
- }
-
- @Override
- public boolean isCancelled() {
- return false;
- }
-
- @Override
- public boolean isDone() {
- return true;
- }
-
- @Override
- public T get() throws InterruptedException, ExecutionException {
- return result;
- }
-
- @Override
- public T get(long timeout, TimeUnit unit) throws InterruptedException,
- ExecutionException, TimeoutException {
- return result;
- }
-
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.core.api;
-
-/**
- * Exception reported when no RPC implementation is found in the system.
- *
- * @deprecated Use {@link org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException} instead.
- */
-@Deprecated
-public class RpcImplementationUnavailableException extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- public RpcImplementationUnavailableException(final String message) {
- super(message);
- }
-
- public RpcImplementationUnavailableException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}