try {
claim = credService.authenticate(new PasswordCredentialsWrapper(username, password));
} catch (AuthenticationException e) {
- LOG.debug("Authentication failed for user '{}' : {}", username, e);
+ LOG.debug("Authentication failed for user '{}'", username, e);
return false;
}
return;
}
} catch (GeneralSecurityException e) {
- LOG.error("Failed decoding a device key with host key: {} {}", keyString, e);
+ LOG.error("Failed decoding a device key with host key: {}", keyString, e);
return;
}
}
mergeParentMixin(rwtx, path, changeData);
rwtx.put(LogicalDatastoreType.CONFIGURATION, path, changeData);
} catch (final InterruptedException | ExecutionException e) {
- LOG.warn("Read from datastore failed when trying to read data for create operation", change, e);
+ LOG.warn("Read from datastore failed when trying to read data for create operation {}", change, e);
}
break;
case REPLACE:
}
rwtx.delete(LogicalDatastoreType.CONFIGURATION, path);
} catch (final InterruptedException | ExecutionException e) {
- LOG.warn("Read from datastore failed when trying to read data for delete operation", change, e);
+ LOG.warn("Read from datastore failed when trying to read data for delete operation {}", change, e);
}
break;
case REMOVE:
try {
tx.commit().get();
- LOG.debug("Stream %s registered successfully.", stream.getName());
+ LOG.debug("Stream {} registered successfully.", stream.getName());
} catch (InterruptedException | ExecutionException e) {
- LOG.warn("Unable to register stream.", e);
+ LOG.warn("Unable to register stream {}.", stream, e);
}
}
try {
tx.commit().get();
- LOG.debug("Stream %s unregistered successfully.", stream);
+ LOG.debug("Stream {} unregistered successfully.", stream);
} catch (InterruptedException | ExecutionException e) {
- LOG.warn("Unable to unregister stream", e);
+ LOG.warn("Unable to unregister stream {}", stream, e);
}
}
}
tag, DocumentedException.ErrorSeverity.ERROR,
Collections.singletonMap(tag.toString(), e.getMessage()));
} catch (final RuntimeException e) {
- throw handleUnexpectedEx("Unexpected exception during netconf operation sort", e);
+ throw handleUnexpectedEx("sort", e);
}
try {
return executeOperationWithHighestPriority(message, netconfOperationExecution);
} catch (final RuntimeException e) {
- throw handleUnexpectedEx("Unexpected exception during netconf operation execution", e);
+ throw handleUnexpectedEx("execution", e);
}
}
netconfOperationServiceSnapshot.close();
}
- private static DocumentedException handleUnexpectedEx(final String message, final Exception exception) {
- LOG.error("{}", message, exception);
+ private static DocumentedException handleUnexpectedEx(final String op, final Exception exception) {
+ LOG.error("Unexpected exception during netconf operation {}", op, exception);
return new DocumentedException("Unexpected error",
DocumentedException.ErrorType.APPLICATION,
DocumentedException.ErrorTag.OPERATION_FAILED,
private static final Logger LOG = LoggerFactory.getLogger(NetconfChunkAggregator.class);
private static final String GOT_PARAM_WHILE_WAITING_FOR_PARAM = "Got byte {} while waiting for {}";
private static final String GOT_PARAM_WHILE_WAITING_FOR_PARAM_PARAM = "Got byte {} while waiting for {}-{}";
+ private static final String GOT_PARAM_WHILE_WAITING_FOR_PARAM_PARAM_PARAM =
+ "Got byte {} while waiting for {}-{}-{}";
public static final int DEFAULT_MAXIMUM_CHUNK_SIZE = 16 * 1024 * 1024;
private enum State {
} else if (byteToCheck == '#') {
state = State.FOOTER_FOUR;
} else {
- LOG.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM_PARAM, byteToCheck, (byte) '#', (byte) '1', (byte) '9');
+ LOG.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM_PARAM_PARAM, byteToCheck, (byte) '#', (byte) '1', (byte) '9');
throw new IllegalStateException("Malformed chunk footer encountered (byte 2)");
}
}
currentSession.sendMessage(new NetconfNotification(filtered.get(), eventTime));
}
} catch (DocumentedException e) {
- LOG.warn(e.toString());
+ LOG.warn("Failed to process notification {}", notification, e);
currentSession.sendMessage(notification);
}
} else {
@Override
public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
- LOG.debug("Internal connection to netconf server was dropped for client: {} on channel: ",
+ LOG.debug("Internal connection to netconf server was dropped for client: {} on channel: {}",
netconfHelloMessageAdditionalHeader.getAddress(), ctx.channel());
callback.onExit(1, "Internal connection to netconf server was dropped for client: "
+ netconfHelloMessageAdditionalHeader.getAddress() + " on channel: " + ctx.channel());
super.channelInactive(ctx);
}
-
-
}
public class ProxyDOMRpcService implements DOMRpcService {
- private static final Logger LOG = LoggerFactory.getLogger(NetconfTopologyManager.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ProxyDOMRpcService.class);
private final ExceptionMapper<DOMRpcException> domRpcExceptionMapper =
new ExceptionMapper<DOMRpcException>("invokeRpc", DOMRpcException.class) {
@Override
public void onFailure(@Nullable final Throwable throwable) {
- LOG.error("{}: Connector failed, {}", remoteDeviceId, throwable);
+ LOG.error("{}: Connector failed", remoteDeviceId, throwable);
}
}, MoreExecutors.directExecutor());
}
private final RemoteDeviceId id;
private final Throwable failure;
- FailedProxyTransactionFacade(RemoteDeviceId id, Throwable failure) {
+ FailedProxyTransactionFacade(final RemoteDeviceId id, final Throwable failure) {
this.id = Objects.requireNonNull(id);
this.failure = Objects.requireNonNull(failure);
}
}
@Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(LogicalDatastoreType store,
- YangInstanceIdentifier path) {
- LOG.debug("{}: Read {} {} - failure {}", id, store, path, failure);
+ public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
+ final YangInstanceIdentifier path) {
+ LOG.debug("{}: Read {} {} - failure", id, store, path, failure);
return Futures.immediateFailedCheckedFuture(ReadFailedException.MAPPER.apply(
failure instanceof Exception ? (Exception)failure : new ReadFailedException("read", failure)));
}
@Override
- public CheckedFuture<Boolean, ReadFailedException> exists(LogicalDatastoreType store, YangInstanceIdentifier path) {
- LOG.debug("{}: Exists {} {} - failure {}", id, store, path, failure);
+ public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
+ final YangInstanceIdentifier path) {
+ LOG.debug("{}: Exists {} {} - failure", id, store, path, failure);
return Futures.immediateFailedCheckedFuture(ReadFailedException.MAPPER.apply(
failure instanceof Exception ? (Exception)failure : new ReadFailedException("read", failure)));
}
@Override
- public void delete(LogicalDatastoreType store, YangInstanceIdentifier path) {
- LOG.debug("{}: Delete {} {} - failure {}", id, store, path, failure);
+ public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ LOG.debug("{}: Delete {} {} - failure", id, store, path, failure);
}
@Override
- public void put(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
- LOG.debug("{}: Put {} {} - failure {}", id, store, path, failure);
+ public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+ final NormalizedNode<?, ?> data) {
+ LOG.debug("{}: Put {} {} - failure", id, store, path, failure);
}
@Override
- public void merge(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
- LOG.debug("{}: Merge {} {} - failure {}", id, store, path, failure);
+ public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+ final NormalizedNode<?, ?> data) {
+ LOG.debug("{}: Merge {} {} - failure", id, store, path, failure);
}
@Override
public @NonNull FluentFuture<? extends @NonNull CommitInfo> commit() {
- LOG.debug("{}: Commit {} {} - failure {}", id, failure);
+ LOG.debug("{}: Commit - failure", id, failure);
return FluentFuture.from(Futures.immediateFailedFuture(failure instanceof Exception
? AsyncWriteTransaction.SUBMIT_EXCEPTION_MAPPER.apply((Exception)failure)
: new TransactionCommitFailedException("commit", failure)));
import org.slf4j.LoggerFactory;
public final class NetconfTopologyUtils {
- private static Logger LOG = LoggerFactory.getLogger(NetconfTopologyUtils.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfTopologyUtils.class);
private static final String DEFAULT_SCHEMA_REPOSITORY_NAME = "sal-netconf-connector";
Futures.addCallback(future, new FutureCallback<NetconfDeviceCapabilities>() {
@Override
public void onSuccess(final NetconfDeviceCapabilities result) {
- LOG.debug("Connector for : " + nodeId.getValue() + " started succesfully");
+ LOG.debug("Connector for {} started succesfully", nodeId.getValue());
}
@Override
public void onFailure(final Throwable throwable) {
- LOG.error("Connector for : " + nodeId.getValue() + " failed");
+ LOG.error("Connector for {} failed", nodeId.getValue(), throwable);
// remove this node from active connectors?
}
}, MoreExecutors.directExecutor());
return future;
}
- protected NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId,
- final NetconfNode node) {
+ protected NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId, final NetconfNode node) {
//setup default values since default value is not supported in mdsal
final long defaultRequestTimeoutMillis = node.getDefaultRequestTimeoutMillis() == null
? DEFAULT_REQUEST_TIMEOUT_MILLIS : node.getDefaultRequestTimeoutMillis();
@Override
public void onFailure(final Throwable throwable) {
- LOG.error("Node {} creation failed: {}", instanceName, throwable);
+ LOG.error("Node {} creation failed", instanceName, throwable);
}
}, MoreExecutors.directExecutor());
return node;
public static void sendErrorMessage(final NetconfSession session,
final DocumentedException sendErrorException) {
- LOG.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
+ LOG.trace("Sending error", sendErrorException);
final Document errorDocument = createDocument(sendErrorException);
ChannelFuture channelFuture = session.sendMessage(new NetconfMessage(errorDocument));
channelFuture.addListener(new SendErrorVerifyingListener(sendErrorException));
}
public static void sendErrorMessage(final Channel channel, final DocumentedException sendErrorException) {
- LOG.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
+ LOG.trace("Sending error", sendErrorException);
final Document errorDocument = createDocument(sendErrorException);
ChannelFuture channelFuture = channel.writeAndFlush(new NetconfMessage(errorDocument));
channelFuture.addListener(new SendErrorVerifyingListener(sendErrorException));
@Override
public void onFailure(final Throwable throwable) {
- LOG.warn("{}: Unexpected error resolving device sources: {}", id, throwable);
+ LOG.warn("{}: Unexpected error resolving device sources", id, throwable);
handleSalInitializationFailure(throwable, listener);
}
};
sessionLock.lock();
try {
if (semaphore != null && !semaphore.tryAcquire()) {
- LOG.warn("Limit of concurrent rpc messages was reached (limit :" + concurentRpcMsgs
- + "). Rpc reply message is needed. Discarding request of Netconf device with id" + id.getName());
+ LOG.warn("Limit of concurrent rpc messages was reached (limit: {}). Rpc reply message is needed. "
+ + "Discarding request of Netconf device with id {}", concurentRpcMsgs, id.getName());
return Futures.immediateFailedFuture(new NetconfDocumentedException(
"Limit of rpc messages was reached (Limit :" + concurentRpcMsgs
+ ") waiting for emptying the queue of Netconf device with id" + id.getName()));
@Override
public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
- LOG.trace("{}: TransactionChain({}) {} SUCCESSFUL", id, chain);
+ LOG.trace("{}: TransactionChain({}) SUCCESSFUL", id, chain);
}
};
public synchronized void onTopologyDeviceConnected(final SchemaContext initialCtx,
final DOMDataBroker broker, final DOMRpcService rpc,
- final NetconfDeviceNotificationService newNotificationService, DOMActionService deviceAction) {
+ final NetconfDeviceNotificationService newNotificationService, final DOMActionService deviceAction) {
Preconditions.checkNotNull(mountService, "Closed");
Preconditions.checkState(topologyRegistration == null, "Already initialized");
private void createNetworkTopologyIfNotPresent(final WriteTransaction writeTx) {
final NetworkTopology networkTopology = new NetworkTopologyBuilder().build();
- LOG.trace("{}: Merging {} container to ensure its presence", id,
- NetworkTopology.QNAME, writeTx.getIdentifier());
+ LOG.trace("{}: Transaction {} merging {} container to ensure its presence", id, writeTx.getIdentifier(),
+ NetworkTopology.QNAME);
writeTx.merge(LogicalDatastoreType.OPERATIONAL, networkTopologyPath, networkTopology);
final Topology topology =
new TopologyBuilder().setTopologyId(new TopologyId(TopologyNetconf.QNAME.getLocalName())).build();
- LOG.trace("{}: Merging {} container to ensure its presence", id,
- Topology.QNAME, writeTx.getIdentifier());
+ LOG.trace("{}: Transaction {} merging {} container to ensure its presence", id, writeTx.getIdentifier(),
+ Topology.QNAME);
writeTx.merge(LogicalDatastoreType.OPERATIONAL, topologyListPath, topology);
}
* 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.netconf.test.tool;
import com.ning.http.client.AsyncCompletionHandler;
private final String destination;
private final String payload;
- DestToPayload(String destination, String payload) {
+ DestToPayload(final String destination, final String payload) {
this.destination = destination;
this.payload = payload;
}
}
}
- public Execution(TesttoolParameters params, ArrayList<DestToPayload> payloads) {
+ public Execution(final TesttoolParameters params, final ArrayList<DestToPayload> payloads) {
this.invokeAsync = params.async;
this.throttle = params.throttle / params.threadAmount;
} else {
LOG.warn("Status code: {}", response.getStatusCode());
LOG.warn("url: {}", request.getUrl());
- LOG.warn(response.getResponseBody());
+ LOG.warn("body: {}", response.getResponseBody());
}
}
} catch (InterruptedException | ExecutionException | IOException e) {
- LOG.warn(e.toString());
+ LOG.warn("Failed to execute request", e);
}
}
LOG.info("End sending sync requests");
}
asyncHttpClient.executeRequest(request, new AsyncCompletionHandler<Response>() {
@Override
- public STATE onStatusReceived(HttpResponseStatus status) throws Exception {
+ public STATE onStatusReceived(final HttpResponseStatus status) throws Exception {
super.onStatusReceived(status);
if (status.getStatusCode() != 200 && status.getStatusCode() != 204) {
if (status.getStatusCode() == 409) {
}
@Override
- public Response onCompleted(Response response) {
+ public Response onCompleted(final Response response) {
semaphore.release();
return response;
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@SuppressFBWarnings({"DM_EXIT", "DM_DEFAULT_ENCODING"})
+@SuppressFBWarnings({"DM_EXIT", "DM_DEFAULT_ENCODING", "SLF4J_LOGGER_SHOULD_BE_FINAL"})
public final class ScaleUtil {
private static final ScheduledExecutorService EXECUTOR = new LoggingWrapperExecutor(4);
private static final Semaphore SEMAPHORE = new Semaphore(0);
deleteFolder(new File(params.distroFolder.getAbsoluteFile() + "/data"));
}
- private static void deleteFolder(File folder) {
+ private static void deleteFolder(final File folder) {
File[] files = folder.listFiles();
if (files != null) { //some JVMs return null for empty dirs
for (File f : files) {
@SuppressWarnings("checkstyle:illegalCatch")
public static class LoggingWrapperExecutor extends ScheduledThreadPoolExecutor {
- public LoggingWrapperExecutor(int corePoolSize) {
+ public LoggingWrapperExecutor(final int corePoolSize) {
super(corePoolSize);
}
@Override
- public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
+ public <V> ScheduledFuture<V> schedule(final Callable<V> callable, final long delay, final TimeUnit unit) {
return super.schedule(new LogOnExceptionCallable<>(callable), delay, unit);
}
private static class LogOnExceptionCallable<T> implements Callable<T> {
private final Callable<T> theCallable;
- LogOnExceptionCallable(Callable<T> theCallable) {
+ LogOnExceptionCallable(final Callable<T> theCallable) {
this.theCallable = theCallable;
}
* 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.netconf.test.tool.client.http.perf;
import com.ning.http.client.AsyncHttpClient;
if (response.getStatusCode() != 200 && response.getStatusCode() != 204) {
LOG.warn("Status code: {}", response.getStatusCode());
LOG.warn("url: {}", request.getUrl());
- LOG.warn(response.getResponseBody());
+ LOG.warn("body: {}", response.getResponseBody());
}
} catch (InterruptedException | ExecutionException | IOException e) {
- LOG.warn(e.toString());
+ LOG.warn("Failed to execute request", e);
}
}
LOG.info("End sending sync requests");
root.setLevel(params.debug ? Level.DEBUG : Level.INFO);
final int threadAmount = params.threadAmount;
- LOG.info("thread amount: " + threadAmount);
+ LOG.info("thread amount: {}", threadAmount);
final int requestsPerThread = params.editCount / params.threadAmount;
- LOG.info("requestsPerThread: " + requestsPerThread);
+ LOG.info("requestsPerThread: {}", requestsPerThread);
final int leftoverRequests = params.editCount % params.threadAmount;
- LOG.info("leftoverRequests: " + leftoverRequests);
-
+ LOG.info("leftoverRequests: {}", leftoverRequests);
LOG.info("Preparing messages");
// Prepare all msgs up front
padding = leftoverRequests;
}
for (int j = 0; j < requestsPerThread + padding; j++) {
- LOG.debug("id: " + (i * requestsPerThread + j));
+ LOG.debug("id: {}", i * requestsPerThread + j);
preparedMessages.add(prepareMessage(i * requestsPerThread + j, editContentString));
}
}
@Override
public synchronized ListenableFuture<? extends T> getSource(final SourceIdentifier sourceIdentifier) {
- ModelData modelData = cachedSchemas.get(sourceIdentifier.toYangFilename());
+ final String fileName = sourceIdentifier.toYangFilename();
+ ModelData modelData = cachedSchemas.get(fileName);
if (modelData != null) {
final SchemaSourceRepresentation restored = restoreAsType(modelData.getId(), modelData.getPath());
return Futures.immediateFuture(representation.cast(restored));
}
- LOG.debug("Source {} not found in cache as {}", sourceIdentifier);
+ LOG.debug("Source {} not found in cache as {}", sourceIdentifier, fileName);
return Futures.immediateFailedFuture(new MissingSchemaSourceException("Source not found", sourceIdentifier));
}
private final DOMNotificationService domNotification;
private final ControllerContext controllerContext;
- private BrokerFacade(DOMRpcService rpcService, DOMDataBroker domDataBroker, DOMNotificationService domNotification,
- ControllerContext controllerContext) {
+ private BrokerFacade(final DOMRpcService rpcService, final DOMDataBroker domDataBroker,
+ final DOMNotificationService domNotification, final ControllerContext controllerContext) {
this.rpcService = Objects.requireNonNull(rpcService);
this.domDataBroker = Objects.requireNonNull(domDataBroker);
this.domNotification = Objects.requireNonNull(domNotification);
this.controllerContext = Objects.requireNonNull(controllerContext);
}
- public static BrokerFacade newInstance(DOMRpcService rpcService, DOMDataBroker domDataBroker,
- DOMNotificationService domNotification, ControllerContext controllerContext) {
+ public static BrokerFacade newInstance(final DOMRpcService rpcService, final DOMDataBroker domDataBroker,
+ final DOMNotificationService domNotification, final ControllerContext controllerContext) {
return new BrokerFacade(rpcService, domDataBroker, domNotification, controllerContext);
}
return readDataViaTransaction(tx, CONFIGURATION, path, withDefa);
}
}
- final String errMsg = "DOM data broker service isn't available for mount point " + path;
- LOG.warn(errMsg);
- throw new RestconfDocumentedException(errMsg);
+ throw dataBrokerUnavailable(path);
}
/**
return readDataViaTransaction(tx, OPERATIONAL, path);
}
}
- final String errMsg = "DOM data broker service isn't available for mount point " + path;
- LOG.warn(errMsg);
- throw new RestconfDocumentedException(errMsg);
+ throw dataBrokerUnavailable(path);
}
/**
point);
return new PutResult(status, future);
}
- final String errMsg = "DOM data broker service isn't available for mount point " + path;
- LOG.warn(errMsg);
- throw new RestconfDocumentedException(errMsg);
+ throw dataBrokerUnavailable(path);
}
public PatchStatusContext patchConfigurationDataWithinTransaction(final PatchContext patchContext)
return postDataViaTransaction(domDataBrokerService.get().newReadWriteTransaction(), CONFIGURATION, path,
payload, mountPoint.getSchemaContext(), insert, point);
}
- final String errMsg = "DOM data broker service isn't available for mount point " + path;
- LOG.warn(errMsg);
- throw new RestconfDocumentedException(errMsg);
+ throw dataBrokerUnavailable(path);
}
// DELETE configuration
if (domDataBrokerService.isPresent()) {
return deleteDataViaTransaction(domDataBrokerService.get().newReadWriteTransaction(), CONFIGURATION, path);
}
- final String errMsg = "DOM data broker service isn't available for mount point " + path;
- LOG.warn(errMsg);
- throw new RestconfDocumentedException(errMsg);
+ throw dataBrokerUnavailable(path);
}
// RPC
private static void checkItemExists(final DOMDataReadWriteTransaction rwTransaction,
final LogicalDatastoreType store, final YangInstanceIdentifier path) {
if (!doesItemExist(rwTransaction, store, path)) {
- final String errMsg = "Operation via Restconf was not executed because data does not exist";
- LOG.trace("{}:{}", errMsg, path);
+ LOG.trace("Operation via Restconf was not executed because data at {} does not exist", path);
rwTransaction.cancel();
throw new RestconfDocumentedException("Data does not exist for path: " + path, ErrorType.PROTOCOL,
ErrorTag.DATA_MISSING);
private static void checkItemDoesNotExists(final DOMDataReadWriteTransaction rwTransaction,
final LogicalDatastoreType store, final YangInstanceIdentifier path) {
if (doesItemExist(rwTransaction, store, path)) {
- final String errMsg = "Operation via Restconf was not executed because data already exists";
- LOG.trace("{}:{}", errMsg, path);
+ LOG.trace("Operation via Restconf was not executed because data at {} already exists", path);
rwTransaction.cancel();
throw new RestconfDocumentedException("Data already exists for path: " + path, ErrorType.PROTOCOL,
ErrorTag.DATA_EXISTS);
tx.merge(store, rootNormalizedPath, parentStructure);
}
+ private static RestconfDocumentedException dataBrokerUnavailable(final YangInstanceIdentifier path) {
+ LOG.warn("DOM data broker service is not available for mount point {}", path);
+ return new RestconfDocumentedException("DOM data broker service is not available for mount point " + path);
+ }
+
private static final class PatchStatusContextHelper {
PatchStatusContext status;
}
return typeAwarecodec.deserialize(String.valueOf(input));
} else {
- LOG.debug("Codec for type \"" + this.type.getQName().getLocalName()
- + "\" is not implemented yet.");
+ LOG.debug("Codec for type \"{}\" is not implemented yet.", type.getQName().getLocalName());
return null;
}
}
} catch (final ClassCastException e) { // TODO remove this catch when everyone use codecs
- LOG.error(
- "ClassCastException was thrown when codec is invoked with parameter " + String.valueOf(input),
- e);
+ LOG.error("ClassCastException was thrown when codec is invoked with parameter {}", input, e);
return null;
}
}
if (typeAwarecodec != null) {
return typeAwarecodec.serialize(input);
} else {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Codec for type \"" + this.type.getQName().getLocalName()
- + "\" is not implemented yet.");
- }
+ LOG.debug("Codec for type \"{}\" is not implemented yet.", type.getQName().getLocalName());
return null;
}
}
} catch (final ClassCastException e) { // TODO remove this catch when everyone use codecs
- LOG.error(
- "ClassCastException was thrown when codec is invoked with parameter " + String.valueOf(input),
- e);
+ LOG.error("ClassCastException was thrown when codec is invoked with parameter {}", input, e);
return input;
}
}
private final DOMMountPoint mountPoint;
private final ControllerContext controllerContext;
- public IdentityrefCodecImpl(final DOMMountPoint mountPoint, ControllerContext controllerContext) {
+ public IdentityrefCodecImpl(final DOMMountPoint mountPoint, final ControllerContext controllerContext) {
this.mountPoint = mountPoint;
this.controllerContext = controllerContext;
}
module = controllerContext.findModuleByNamespace(validNamespace);
}
if (module == null) {
- LOG.info("Module for namespace " + validNamespace + " wasn't found.");
+ LOG.info("Module for namespace {} was not found.", validNamespace);
return null;
}
return module;
private final ControllerContext controllerContext;
- private RestconfImpl(BrokerFacade broker, ControllerContext controllerContext) {
+ private RestconfImpl(final BrokerFacade broker, final ControllerContext controllerContext) {
this.broker = broker;
this.controllerContext = controllerContext;
}
- public static RestconfImpl newInstance(BrokerFacade broker, ControllerContext controllerContext) {
+ public static RestconfImpl newInstance(final BrokerFacade broker, final ControllerContext controllerContext) {
return new RestconfImpl(broker, controllerContext);
}
if (!identifier.contains(ControllerContext.MOUNT)) {
final String errMsg = "URI has bad format. If modules behind mount point should be showed,"
+ " URI has to end with " + ControllerContext.MOUNT;
- LOG.debug(errMsg + " for " + identifier);
+ LOG.debug("{} for {}", errMsg, identifier);
throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
}
}
if (module == null) {
- final String errMsg = "Module with name '" + nameRev.getKey() + "' and revision '"
- + nameRev.getValue() + "' was not found.";
- LOG.debug(errMsg);
- throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
+ LOG.debug("Module with name '{}' and revision '{}' was not found.", nameRev.getKey(), nameRev.getValue());
+ throw new RestconfDocumentedException("Module with name '" + nameRev.getKey() + "' and revision '"
+ + nameRev.getValue() + "' was not found.", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
}
final Module restconfModule = getRestconfModule();
modules = this.controllerContext.getAllModules(mountPoint);
} else {
- final String errMsg =
- "URI has bad format. If operations behind mount point should be showed, URI has to " + "end with ";
- LOG.debug(errMsg + ControllerContext.MOUNT + " for " + identifier);
- throw new RestconfDocumentedException(errMsg + ControllerContext.MOUNT, ErrorType.PROTOCOL,
- ErrorTag.INVALID_VALUE);
+ final String errMsg = "URI has bad format. If operations behind mount point should be showed, URI has to "
+ + " end with " + ControllerContext.MOUNT;
+ LOG.debug("{} for {}", errMsg, identifier);
+ throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
}
return operationsFromModulesToNormalizedContext(modules, mountPoint);
final Splitter splitter = Splitter.on('/').omitEmptyStrings();
final List<String> pathArgs = splitter.splitToList(moduleNameAndRevision);
if (pathArgs.size() < 2) {
- LOG.debug("URI has bad format. It should be \'moduleName/yyyy-MM-dd\' " + identifier);
+ LOG.debug("URI has bad format. It should be \'moduleName/yyyy-MM-dd\' {}", identifier);
throw new RestconfDocumentedException(
"URI has bad format. End of URI should be in format \'moduleName/yyyy-MM-dd\'", ErrorType.PROTOCOL,
ErrorTag.INVALID_VALUE);
try {
return new SimpleImmutableEntry<>(pathArgs.get(0), Revision.of(pathArgs.get(1)));
} catch (final DateTimeParseException e) {
- LOG.debug("URI has bad format. It should be \'moduleName/yyyy-MM-dd\' " + identifier);
+ LOG.debug("URI has bad format. It should be \'moduleName/yyyy-MM-dd\' {}", identifier);
throw new RestconfDocumentedException("URI has bad format. It should be \'moduleName/yyyy-MM-dd\'",
ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE, e);
}
@Override
public NormalizedNodeContext invokeRpc(final String identifier, final String noPayload, final UriInfo uriInfo) {
- if (noPayload != null && !CharMatcher.WHITESPACE.matchesAllOf(noPayload)) {
+ if (noPayload != null && !CharMatcher.whitespace().matchesAllOf(noPayload)) {
throw new RestconfDocumentedException("Content must be empty.", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
}
final String remoteRpcName = identifier.substring(startOfRemoteRpcName);
identifierEncoded = remoteRpcName;
- } else if (identifier.indexOf("/") != CHAR_NOT_FOUND) {
- final String slashErrorMsg = String.format(
- "Identifier %n%s%ncan\'t contain slash "
- + "character (/).%nIf slash is part of identifier name then use %%2F placeholder.",
- identifier);
- LOG.debug(slashErrorMsg);
- throw new RestconfDocumentedException(slashErrorMsg, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
+ } else if (identifier.indexOf('/') != CHAR_NOT_FOUND) {
+ LOG.debug("Identifier {} cannot contain slash character (/).", identifier);
+ throw new RestconfDocumentedException(String.format("Identifier %n%s%ncan\'t contain slash character (/).%n"
+ + "If slash is part of identifier name then use %%2F placeholder.", identifier), ErrorType.PROTOCOL,
+ ErrorTag.INVALID_VALUE);
} else {
identifierEncoded = identifier;
schemaContext = this.controllerContext.getGlobalSchema();
}
if (rpc == null) {
- LOG.debug("RPC " + identifierDecoded + " does not exist.");
+ LOG.debug("RPC {} does not exist.", identifierDecoded);
throw new RestconfDocumentedException("RPC does not exist.", ErrorType.RPC, ErrorTag.UNKNOWN_ELEMENT);
}
if (!rpc.getInput().getChildNodes().isEmpty()) {
- LOG.debug("RPC " + rpc + " does not need input value.");
+ LOG.debug("RPC {} does not need input value.", rpc);
throw new RestconfDocumentedException("RPC " + rpc + " does not take any input value.",
ErrorType.RPC, ErrorTag.INVALID_VALUE);
}
if (retValue.getErrors().isEmpty()) {
return retValue;
}
- LOG.debug("RpcError message", retValue.getErrors());
+ LOG.debug("RpcError message {}", retValue.getErrors());
throw new RestconfDocumentedException("RpcError message", null, retValue.getErrors());
} catch (final InterruptedException e) {
final String errMsg = "The operation was interrupted while executing and did not complete.";
- LOG.debug("Rpc Interrupt - " + errMsg, e);
+ LOG.debug("Rpc Interrupt - {}", errMsg, e);
throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION, e);
} catch (final ExecutionException e) {
LOG.debug("Execution RpcError: ", e);
}
} catch (final CancellationException e) {
final String errMsg = "The operation was cancelled while executing.";
- LOG.debug("Cancel RpcExecution: " + errMsg, e);
+ LOG.debug("Cancel RpcExecution: {}", errMsg, e);
throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION);
}
}
final Object pathValue = path.isPresent() ? path.get().getValue() : null;
if (!(pathValue instanceof YangInstanceIdentifier)) {
- final String errMsg = "Instance identifier was not normalized correctly ";
- LOG.debug(errMsg + rpcQName);
- throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED);
+ LOG.debug("Instance identifier {} was not normalized correctly", rpcQName);
+ throw new RestconfDocumentedException("Instance identifier was not normalized correctly",
+ ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED);
}
final YangInstanceIdentifier pathIdentifier = (YangInstanceIdentifier) pathValue;
}
if (Strings.isNullOrEmpty(streamName)) {
- final String errMsg = "Path is empty or contains value node which is not Container or List build-in type.";
- LOG.debug(errMsg + pathIdentifier);
- throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
+ LOG.debug("Path is empty or contains value node which is not Container or List built-in type at {}",
+ pathIdentifier);
+ throw new RestconfDocumentedException("Path is empty or contains value node which is not Container or List "
+ + "built-in type.", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
}
final QName outputQname = QName.create(rpcQName, "output");
private static RpcDefinition findRpc(final SchemaContext schemaContext, final String identifierDecoded) {
final String[] splittedIdentifier = identifierDecoded.split(":");
if (splittedIdentifier.length != 2) {
- final String errMsg = identifierDecoded + " couldn't be splitted to 2 parts (module:rpc name)";
- LOG.debug(errMsg);
- throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.INVALID_VALUE);
+ LOG.debug("{} could not be split to 2 parts (module:rpc name)", identifierDecoded);
+ throw new RestconfDocumentedException(identifierDecoded + " could not be split to 2 parts "
+ + "(module:rpc name)", ErrorType.APPLICATION, ErrorTag.INVALID_VALUE);
}
for (final Module module : schemaContext.getModules()) {
if (module.getName().equals(splittedIdentifier[0])) {
data = this.broker.readConfigurationData(normalizedII, withDefa);
}
if (data == null) {
- final String errMsg =
- "Request could not be completed because the relevant data model content does not exist ";
- LOG.debug(errMsg + identifier);
- throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.DATA_MISSING);
+ throw dataMissing(identifier);
}
return new NormalizedNodeContext(iiWithData, data,
QueryParametersParser.parseWriterParameters(uriInfo, tagged));
data = this.broker.readOperationalData(normalizedII);
}
if (data == null) {
- final String errMsg =
- "Request could not be completed because the relevant data model content does not exist ";
- LOG.debug(errMsg + identifier);
- throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.DATA_MISSING);
+ throw dataMissing(identifier);
}
return new NormalizedNodeContext(iiWithData, data, QueryParametersParser.parseWriterParameters(uriInfo));
}
+ private static RestconfDocumentedException dataMissing(final String identifier) {
+ LOG.debug("Request could not be completed because the relevant data model content does not exist {}",
+ identifier);
+ return new RestconfDocumentedException("Request could not be completed because the relevant data model content "
+ + "does not exist", ErrorType.APPLICATION, ErrorTag.DATA_MISSING);
+ }
+
@Override
public Response updateConfigurationData(final String identifier, final NormalizedNodeContext payload,
final UriInfo uriInfo) {
} catch (final TransactionCommitFailedException e) {
if (e instanceof OptimisticLockFailedException) {
if (--tries <= 0) {
- LOG.debug("Got OptimisticLockFailedException on last try - failing " + identifier);
+ LOG.debug("Got OptimisticLockFailedException on last try - failing {}", identifier);
throw new RestconfDocumentedException(e.getMessage(), e, e.getErrorList());
}
- LOG.debug("Got OptimisticLockFailedException - trying again " + identifier);
+ LOG.debug("Got OptimisticLockFailedException - trying again {}", identifier);
} else {
- LOG.debug("Update failed for " + identifier, e);
+ LOG.debug("Update failed for {}", identifier, e);
throw new RestconfDocumentedException(e.getMessage(), e, e.getErrorList());
}
}
} catch (final RestconfDocumentedException e) {
throw e;
} catch (final TransactionCommitFailedException e) {
- LOG.info("Error creating data " + (uriInfo != null ? uriInfo.getPath() : ""), e);
+ LOG.info("Error creating data {}", uriInfo != null ? uriInfo.getPath() : "", e);
throw new RestconfDocumentedException(e.getMessage(), e, e.getErrorList());
}
try {
uriBuilder.path(this.controllerContext.toFullRestconfIdentifier(normalizedII, mountPoint));
} catch (final Exception e) {
- LOG.info("Location for instance identifier" + normalizedII + "wasn't created", e);
+ LOG.info("Location for instance identifier {} was not created", normalizedII, e);
return null;
}
return uriBuilder.build();
return uriToWebsocketServerBuilder.replacePath(streamName).build();
}
- private String getWsScheme(UriInfo uriInfo) {
+ private String getWsScheme(final UriInfo uriInfo) {
URI uri = uriInfo.getAbsolutePath();
if (uri == null) {
return "ws";
*/
public void addSubscriber(final Channel subscriber) {
if (!subscriber.isActive()) {
- LOG.debug("Channel is not active between websocket server and subscriber {}" + subscriber.remoteAddress());
+ LOG.debug("Channel is not active between websocket server and subscriber {}", subscriber.remoteAddress());
}
final Event event = new Event(EventType.REGISTER);
event.setSubscriber(subscriber);
if (LOG.isDebugEnabled()) {
LOG.debug(
"Value is not instance of IdentityrefTypeDefinition but is {}. "
- + "Therefore NULL is used as translation of - {}",
+ + "Therefore NULL is used as translation of - {}",
input == null ? "null" : input.getClass(), String.valueOf(input));
}
return null;
}
return typeAwarecodec.deserialize(String.valueOf(input));
} else {
- LOG.debug("Codec for type \"" + this.type.getQName().getLocalName()
- + "\" is not implemented yet.");
+ LOG.debug("Codec for type \"{}\" is not implemented yet.", type.getQName().getLocalName());
return null;
}
}
} catch (final ClassCastException e) { // TODO remove this catch when everyone use codecs
- LOG.error(
- "ClassCastException was thrown when codec is invoked with parameter " + String.valueOf(input),
- e);
+ LOG.error("ClassCastException was thrown when codec is invoked with parameter {}", input, e);
return null;
}
}
return typeAwarecodec.serialize(input);
} else {
if (LOG.isDebugEnabled()) {
- LOG.debug("Codec for type \"" + this.type.getQName().getLocalName()
- + "\" is not implemented yet.");
+ LOG.debug("Codec for type \"{}\" is not implemented yet.", type.getQName().getLocalName());
}
return null;
}
}
} catch (final ClassCastException e) { // TODO remove this catch when everyone use codecs
- LOG.error(
- "ClassCastException was thrown when codec is invoked with parameter " + String.valueOf(input),
- e);
+ LOG.error("ClassCastException was thrown when codec is invoked with parameter {}", input, e);
return input;
}
}
-
}
public static class IdentityrefCodecImpl implements IdentityrefCodec<IdentityValuesDTO> {
module = schemaContext.findModules(validNamespace).iterator().next();
}
if (module == null) {
- LOG.info("Module for namespace " + validNamespace + " wasn't found.");
+ LOG.info("Module for namespace {} was not found.", validNamespace);
return null;
}
return module;
@Override
public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
- LOG.trace("TransactionChain({}) {} SUCCESSFUL", chain);
+ LOG.trace("TransactionChain({}) SUCCESSFUL", chain);
}
};
return JsonNormalizedNodeBodyReader.readFrom(instanceIdentifierContext, entityStream, isPost);
}
- private String toJson(final PatchStatusContext patchStatusContext) throws IOException {
+ private static String toJson(final PatchStatusContext patchStatusContext) throws IOException {
final PatchJsonBodyWriter writer = new PatchJsonBodyWriter();
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
writer.writeTo(patchStatusContext, PatchStatusContext.class, null, EMPTY_ANNOTATIONS,
pathValue = path.get().getValue();
}
if (!(pathValue instanceof YangInstanceIdentifier)) {
- final String errMsg = "Instance identifier was not normalized correctly ";
- LOG.debug(errMsg + qualifiedName);
- throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED);
+ LOG.debug("Instance identifier {} was not normalized correctly", qualifiedName);
+ throw new RestconfDocumentedException("Instance identifier was not normalized correctly",
+ ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED);
}
return (YangInstanceIdentifier) pathValue;
}
FutureCallbackTx.addCallback(future, PatchData.PATCH_TX_TYPE, response);
if (!response.result) {
- final String errMsg = "Operation via Restconf was not executed because data does not exist";
- LOG.trace("{}:{}", errMsg, path);
- throw new RestconfDocumentedException(
- "Data does not exist", ErrorType.PROTOCOL, ErrorTag.DATA_MISSING, path);
+ LOG.trace("Operation via Restconf was not executed because data at {} does not exist", path);
+ throw new RestconfDocumentedException("Data does not exist", ErrorType.PROTOCOL, ErrorTag.DATA_MISSING,
+ path);
}
}
FutureCallbackTx.addCallback(future, PatchData.PATCH_TX_TYPE, response);
if (response.result) {
- final String errMsg = "Operation via Restconf was not executed because data already exists";
- LOG.trace("{}:{}", errMsg, path);
- throw new RestconfDocumentedException(
- "Data already exists", ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS, path);
+ LOG.trace("Operation via Restconf was not executed because data at {} already exists", path);
+ throw new RestconfDocumentedException("Data already exists", ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS,
+ path);
}
}
}
if (response.getErrors().isEmpty()) {
return response;
}
- LOG.debug("RpcError message", response.getErrors());
+ LOG.debug("RpcError message {}", response.getErrors());
throw new RestconfDocumentedException("RPCerror message ", null, response.getErrors());
} catch (final CancellationException e) {
final String errMsg = "The operation was cancelled while executing.";
- LOG.debug("Cancel RpcExecution: " + errMsg, e);
+ LOG.debug("Cancel RpcExecution: {}", errMsg, e);
throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION, e);
}
}
transactionChainHandler.reset();
// throw error
- final String errMsg = "Operation via Restconf was not executed because data does not exist";
- LOG.trace("{}:{}", errMsg, path);
+ LOG.trace("Operation via Restconf was not executed because data at {} does not exist", path);
throw new RestconfDocumentedException(
"Data does not exist", ErrorType.PROTOCOL, ErrorTag.DATA_MISSING, path);
}
transactionChainHandler.reset();
// throw error
- final String errMsg = "Operation via Restconf was not executed because data already exists";
- LOG.trace("{}:{}", errMsg, path);
+ LOG.trace("Operation via Restconf was not executed because data at {} already exists", path);
throw new RestconfDocumentedException(
"Data already exists", ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS, path);
}
mountPoint = mountPointIdentifier.getMountPoint();
modules = ref.getModules(mountPoint);
} else {
- final String errMsg =
- "URI has bad format. If operations behind mount point should be showed, URI has to end with ";
- LOG.debug(errMsg + RestconfConstants.MOUNT + " for " + identifier);
+ final String errMsg = "URI has bad format. If operations behind mount point should be showed, URI has to "
+ + " end with " + RestconfConstants.MOUNT;
+ LOG.debug("{} for {}", errMsg, identifier);
throw new RestconfDocumentedException(errMsg + RestconfConstants.MOUNT, ErrorType.PROTOCOL,
ErrorTag.INVALID_VALUE);
}
*/
public void addSubscriber(final Channel subscriber) {
if (!subscriber.isActive()) {
- LOG.debug("Channel is not active between websocket server and subscriber {}" + subscriber.remoteAddress());
+ LOG.debug("Channel is not active between websocket server and subscriber {}", subscriber.remoteAddress());
}
final Event event = new Event(EventType.REGISTER);
event.setSubscriber(subscriber);
// check if more than one slash is not used as path separator
if (identifier.contains(
String.valueOf(RestconfConstants.SLASH).concat(String.valueOf(RestconfConstants.SLASH)))) {
- LOG.debug("URI has bad format. It should be \'moduleName/yyyy-MM-dd\' " + identifier);
+ LOG.debug("URI has bad format. It should be \'moduleName/yyyy-MM-dd\' {}", identifier);
throw new RestconfDocumentedException(
"URI has bad format. End of URI should be in format \'moduleName/yyyy-MM-dd\'", ErrorType.PROTOCOL,
ErrorTag.INVALID_VALUE);
// Create JS file
File resourcesJsFile = new File(outputDir, "resources.js");
if (!resourcesJsFile.createNewFile()) {
- LOG.info("File " + resourcesJsFile + " already exists.");
+ LOG.info("File {} already exists.", resourcesJsFile);
}
try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(resourcesJsFile))) {
private final ObjectMapper mapper = new ObjectMapper();
private final DOMSchemaService schemaService;
- protected BaseYangSwaggerGenerator(Optional<DOMSchemaService> schemaService) {
+ protected BaseYangSwaggerGenerator(final Optional<DOMSchemaService> schemaService) {
this.schemaService = schemaService.orElse(null);
this.mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
}
models = this.jsonConverter.convertToJsonSchema(module, schemaContext);
doc.setModels(models);
if (LOG.isDebugEnabled()) {
- LOG.debug(this.mapper.writeValueAsString(doc));
+ LOG.debug("Document: {}", this.mapper.writeValueAsString(doc));
}
} catch (IOException e) {
LOG.error("Exception occured in ModelGenerator", e);