* 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.rest.impl;
+package org.opendaylight.controller.sal.restconf.impl;
+import java.math.BigInteger;
import java.util.Collection;
import java.util.Collections;
+import org.opendaylight.controller.config.yang.md.sal.rest.connector.Config;
+import org.opendaylight.controller.config.yang.md.sal.rest.connector.Get;
+import org.opendaylight.controller.config.yang.md.sal.rest.connector.Operational;
+import org.opendaylight.controller.config.yang.md.sal.rest.connector.Post;
+import org.opendaylight.controller.config.yang.md.sal.rest.connector.Put;
+import org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorRuntimeMXBean;
+import org.opendaylight.controller.config.yang.md.sal.rest.connector.Rpcs;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
import org.opendaylight.controller.sal.core.api.Provider;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.controller.sal.rest.api.RestConnector;
-import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
-import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
import org.opendaylight.controller.sal.streams.websockets.WebSocketServer;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
-public class RestconfProviderImpl implements Provider, AutoCloseable, RestConnector {
+public class RestconfProviderImpl implements Provider, AutoCloseable, RestConnector, RestConnectorRuntimeMXBean {
public final static String NOT_INITALIZED_MSG = "Restconf is not initialized yet. Please try again later";
+ private final StatisticsRestconfServiceWrapper stats = StatisticsRestconfServiceWrapper.getInstance();
private ListenerRegistration<SchemaContextListener> listenerRegistration;
private PortNumber port;
public void setWebsocketPort(PortNumber port) {
}
webSocketServerThread.interrupt();
}
+
+ @Override
+ public Config getConfig() {
+ Config config = new Config();
+ Get get = new Get();
+ get.setReceivedRequests(stats.getConfigGet());
+ config.setGet(get);
+ Post post = new Post();
+ post.setReceivedRequests(stats.getConfigPost());
+ config.setPost(post);
+ Put put = new Put();
+ put.setReceivedRequests(stats.getConfigPut());
+ config.setPut(put);
+ return config;
+ }
+
+ @Override
+ public Operational getOperational() {
+ BigInteger opGet = stats.getOperationalGet();
+ Operational operational = new Operational();
+ Get get = new Get();
+ get.setReceivedRequests(opGet);
+ operational.setGet(get);
+ return operational;
+ }
+
+ @Override
+ public Rpcs getRpcs() {
+ BigInteger rpcInvoke = stats.getRpc();
+ Rpcs rpcs = new Rpcs();
+ rpcs.setReceivedRequests(rpcInvoke);
+ return rpcs ;
+ }
}
--- /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.restconf.impl;
+
+import java.math.BigInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import org.opendaylight.controller.sal.rest.api.RestconfService;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.Node;
+
+public class StatisticsRestconfServiceWrapper implements RestconfService {
+
+ AtomicLong operationalGet = new AtomicLong();
+ AtomicLong configGet = new AtomicLong();
+ AtomicLong rpc = new AtomicLong();
+ AtomicLong configPost = new AtomicLong();
+ AtomicLong configPut = new AtomicLong();
+ AtomicLong configDelete = new AtomicLong();
+
+ private static final StatisticsRestconfServiceWrapper INSTANCE = new StatisticsRestconfServiceWrapper(RestconfImpl.getInstance());
+
+ final RestconfService delegate;
+
+ private StatisticsRestconfServiceWrapper(RestconfService delegate) {
+ this.delegate = delegate;
+ }
+
+ public static StatisticsRestconfServiceWrapper getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public Object getRoot() {
+ return delegate.getRoot();
+ }
+
+ @Override
+ public StructuredData getModules(UriInfo uriInfo) {
+ return delegate.getModules(uriInfo);
+ }
+
+ @Override
+ public StructuredData getModules(String identifier, UriInfo uriInfo) {
+ return delegate.getModules(identifier, uriInfo);
+ }
+
+ @Override
+ public StructuredData getModule(String identifier, UriInfo uriInfo) {
+ return delegate.getModule(identifier, uriInfo);
+ }
+
+ @Override
+ public StructuredData getOperations(UriInfo uriInfo) {
+ return delegate.getOperations(uriInfo);
+ }
+
+ @Override
+ public StructuredData getOperations(String identifier, UriInfo uriInfo) {
+ return delegate.getOperations(identifier, uriInfo);
+ }
+
+ @Override
+ public StructuredData invokeRpc(String identifier, CompositeNode payload, UriInfo uriInfo) {
+ rpc.incrementAndGet();
+ return delegate.invokeRpc(identifier, payload, uriInfo);
+ }
+
+ @Override
+ public StructuredData invokeRpc(String identifier, String noPayload, UriInfo uriInfo) {
+ rpc.incrementAndGet();
+ return delegate.invokeRpc(identifier, noPayload, uriInfo);
+ }
+
+ @Override
+ public NormalizedNodeContext readConfigurationData(String identifier, UriInfo uriInfo) {
+ configGet.incrementAndGet();
+ return delegate.readConfigurationData(identifier, uriInfo);
+ }
+
+ @Override
+ public NormalizedNodeContext readOperationalData(String identifier, UriInfo uriInfo) {
+ operationalGet.incrementAndGet();
+ return delegate.readOperationalData(identifier, uriInfo);
+ }
+
+ @Override
+ public Response updateConfigurationData(String identifier, Node<?> payload) {
+ configPut.incrementAndGet();
+ return delegate.updateConfigurationData(identifier, payload);
+ }
+
+ @Override
+ public Response createConfigurationData(String identifier, Node<?> payload) {
+ configPost.incrementAndGet();
+ return delegate.createConfigurationData(identifier, payload);
+ }
+
+ @Override
+ public Response createConfigurationData(Node<?> payload) {
+ configPost.incrementAndGet();
+ return delegate.createConfigurationData(payload);
+ }
+
+ @Override
+ public Response deleteConfigurationData(String identifier) {
+ return delegate.deleteConfigurationData(identifier);
+ }
+
+ @Override
+ public Response subscribeToStream(String identifier, UriInfo uriInfo) {
+ return delegate.subscribeToStream(identifier, uriInfo);
+ }
+
+ @Override
+ public StructuredData getAvailableStreams(UriInfo uriInfo) {
+ return delegate.getAvailableStreams(uriInfo);
+ }
+
+ public BigInteger getConfigDelete() {
+ return BigInteger.valueOf(configDelete.get());
+ }
+
+ public BigInteger getConfigGet() {
+ return BigInteger.valueOf(configGet.get());
+ }
+
+ public BigInteger getConfigPost() {
+ return BigInteger.valueOf(configPost.get());
+ }
+
+ public BigInteger getConfigPut() {
+ return BigInteger.valueOf(configPut.get());
+ }
+
+ public BigInteger getOperationalGet() {
+ return BigInteger.valueOf(operationalGet.get());
+ }
+
+ public BigInteger getRpc() {
+ return BigInteger.valueOf(rpc.get());
+ }
+
+}