} else {
flowId = FlowUtil.createAlienFlowId(input.getTableId());
}
-
+ LOG.trace("Calling add flow for flow with ID ={}.", flowId);
final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(input);
final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create(input.getTableId(), flowId);
deviceContext.getDeviceFlowRegistry().store(flowRegistryKey, flowDescriptor);
- final ListenableFuture<RpcResult<AddFlowOutput>> future = flowAdd.processFlowModInputBuilders(flowAdd.toFlowModInputs(input));
+ final ListenableFuture<RpcResult<AddFlowOutput>> future =
+ flowAdd.processFlowModInputBuilders(flowAdd.toFlowModInputs(input));
Futures.addCallback(future, new FutureCallback<RpcResult<AddFlowOutput>>() {
@Override
public void onSuccess(final RpcResult<AddFlowOutput> rpcResult) {
if (rpcResult.isSuccessful()) {
- LOG.debug("flow add finished without error, id={}", flowId.getValue());
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("flow add with id={},finished without error,", flowId.getValue());
+ }
if (itemLifecycleListener != null) {
KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
deviceContext.getDeviceState().getNodeInstanceIdentifier());
itemLifecycleListener.onAdded(flowPath, flowBuilder.build());
}
} else {
- LOG.error("flow add failed with id={}, errors={}", flowId.getValue(), errorsToString(rpcResult.getErrors()));
- }
+ LOG.error("flow add failed for id={}, errors={}", flowId.getValue(), errorsToString(rpcResult.getErrors()));
+ }
}
@Override
public void onFailure(final Throwable throwable) {
deviceContext.getDeviceFlowRegistry().markToBeremoved(flowRegistryKey);
- LOG.trace("Service call for adding flows failed, id={}.", flowId.getValue(), throwable);
+ LOG.error("Service call for adding flow with id={} failed, reason {} .", flowId.getValue(), throwable);
}
});
public Future<RpcResult<RemoveFlowOutput>> removeFlow(final RemoveFlowInput input) {
LOG.trace("Calling remove flow for flow with ID ={}.", input.getFlowRef());
- final ListenableFuture<RpcResult<RemoveFlowOutput>> future = flowRemove.processFlowModInputBuilders(flowRemove.toFlowModInputs(input));
+ final ListenableFuture<RpcResult<RemoveFlowOutput>> future =
+ flowRemove.processFlowModInputBuilders(flowRemove.toFlowModInputs(input));
Futures.addCallback(future, new FutureCallback<RpcResult<RemoveFlowOutput>>() {
@Override
public void onSuccess(final RpcResult<RemoveFlowOutput> result) {
if (result.isSuccessful()) {
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("flow removed finished without error,");
+ }
FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(input);
deviceContext.getDeviceFlowRegistry().markToBeremoved(flowRegistryKey);
if (itemLifecycleListener != null) {
- final FlowDescriptor flowDescriptor = deviceContext.getDeviceFlowRegistry().retrieveIdForFlow(flowRegistryKey);
+ final FlowDescriptor flowDescriptor =
+ deviceContext.getDeviceFlowRegistry().retrieveIdForFlow(flowRegistryKey);
if (flowDescriptor != null) {
KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
deviceContext.getDeviceState().getNodeInstanceIdentifier());
}
}
} else {
- LOG.error("Flow remove failed with errors : {}", errorsToString(result.getErrors()));
+ LOG.error("Flow remove failed with errors : {}",errorsToString(result.getErrors()));
}
}
@Override
public void onFailure(final Throwable throwable) {
- LOG.trace("Flow remove failed..", throwable);
+ LOG.error("Service call for removing flow with id {} failed ,reason {}",input.getFlowRef().getValue(), throwable);
}
});
@Override
public void onFailure(final Throwable throwable) {
- LOG.debug("Flow update failed", throwable);
+ LOG.error("Service call for updating flow failed, reason{}", throwable);
}
});
return future;
*/
package org.opendaylight.openflowplugin.impl.services;
+import java.util.Collection;
import java.util.concurrent.Future;
import com.google.common.annotations.VisibleForTesting;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public void onSuccess(RpcResult<AddGroupOutput> result) {
if (result.isSuccessful()) {
- LOG.debug("group add finished without error, id={}", input.getGroupId().getValue());
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("group add with id={} finished without error", input.getGroupId().getValue());
+ }
addIfNecessaryToDS(input.getGroupId(), input);
- }
+ } else {
+ LOG.error("group add with id={} failed, errors={}", input.getGroupId().getValue(),
+ errorsToString(result.getErrors()));
+ }
}
@Override
public void onFailure(Throwable t) {
- LOG.error("group add failed for id={}. Exception: {}", input.getGroupId().getValue(), t);
+ LOG.error("Service call for group add failed for id={}. Exception: {}",
+ input.getGroupId().getValue(), t);
}
});
@Override
public void onSuccess(@Nullable RpcResult<UpdateGroupOutput> result) {
if (result.isSuccessful()) {
- LOG.debug("Group update succeded");
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Group update for original id {} succeded", input.getOriginalGroup().getGroupId().getValue());
+ }
removeIfNecessaryFromDS(input.getOriginalGroup().getGroupId());
addIfNecessaryToDS(input.getUpdatedGroup().getGroupId(), input.getUpdatedGroup());
+ }else{
+ LOG.error("group update failed with id={}, errors={}", input.getOriginalGroup().getGroupId(),
+ errorsToString(result.getErrors()));
}
}
@Override
public void onFailure(Throwable t) {
- LOG.debug("Group update failed for id={}. Exception: {}", input.getOriginalGroup().getGroupId(), t);
+ LOG.error("Service call for group update failed for id={}. Exception: {}",
+ input.getOriginalGroup().getGroupId(), t);
}
});
return resultFuture;
@Override
public void onSuccess(@Nullable RpcResult<RemoveGroupOutput> result) {
if (result.isSuccessful()) {
- LOG.debug("Group remove succeded");
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Group remove for id {} succeded", input.getGroupId().getValue());
+ }
removeIfNecessaryFromDS(input.getGroupId());
+ }else{
+ LOG.error("group remove failed with id={}, errors={}", input.getGroupId().getValue(),
+ errorsToString(result.getErrors()));
}
}
@Override
public void onFailure(Throwable t) {
- LOG.error("Group remove failed for id={}. Exception: {}", input.getGroupId(), t);
+ LOG.error("Service call for group remove failed for id={}. Exception: {}",
+ input.getGroupId().getValue(), t);
}
});
return resultFuture;
}
}
- static KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group, GroupKey> createGroupPath(final GroupId groupId, final KeyedInstanceIdentifier<Node, NodeKey> nodePath) {
- return nodePath.augmentation(FlowCapableNode.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group.class, new GroupKey(groupId));
+ static KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group, GroupKey>
+ createGroupPath(final GroupId groupId, final KeyedInstanceIdentifier<Node, NodeKey> nodePath) {
+ return nodePath.augmentation(FlowCapableNode.class).
+ child(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group.class, new GroupKey(groupId));
+ }
+
+ private final String errorsToString(final Collection<RpcError> rpcErrors) {
+ final StringBuilder errors = new StringBuilder();
+ if ((null != rpcErrors) && (rpcErrors.size() > 0)) {
+ for (final RpcError rpcError : rpcErrors) {
+ errors.append(rpcError.getMessage());
+ }
+ }
+ return errors.toString();
}
}
*/
package org.opendaylight.openflowplugin.impl.services;
+import java.util.Collection;
import java.util.concurrent.Future;
import com.google.common.util.concurrent.FutureCallback;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public void onSuccess(@Nullable RpcResult<AddMeterOutput> result) {
if (result.isSuccessful()) {
- LOG.debug("Meter add finished without error, id={}", input.getMeterId());
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Meter add finished without error, id={}", input.getMeterId());
+ }
addIfNecessaryToDS(input.getMeterId(),input);
+ }else{
+ LOG.error("Meter add with id {} failed with error {}", input.getMeterId(),
+ errorsToString(result.getErrors()));
}
}
@Override
public void onSuccess(@Nullable RpcResult<UpdateMeterOutput> result) {
if (result.isSuccessful()) {
- LOG.debug("Meter update finished without error, id={}", input.getOriginalMeter().getMeterId());
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Meter update finished without error, id={}", input.getOriginalMeter().getMeterId());
+ }
if (itemLifecycleListener != null) {
removeIfNecessaryFromDS(input.getOriginalMeter().getMeterId());
addIfNecessaryToDS(input.getUpdatedMeter().getMeterId(),input.getUpdatedMeter());
}
+ }else{
+ LOG.error("Meter update with id {} failed with error {}", input.getOriginalMeter().getMeterId(),
+ errorsToString(result.getErrors()));
}
}
@Override
public void onFailure(Throwable t) {
- LOG.error("Meter update failed. for id={}. Exception {}.",input.getOriginalMeter().getMeterId(),t);
+ LOG.error("Service call for meter update failed. for id={}. Exception {}.",
+ input.getOriginalMeter().getMeterId(),t);
}
});
return resultFuture;
@Override
public void onSuccess(@Nullable RpcResult<RemoveMeterOutput> result) {
if (result.isSuccessful()) {
- LOG.debug("Meter remove finished without error, id={}", input.getMeterId());
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Meter remove finished without error, id={}", input.getMeterId());
+ }
removeIfNecessaryFromDS(input.getMeterId());
+ }else{
+ LOG.error("Meter remove with id {} failed with error {}", input.getMeterId(),
+ errorsToString(result.getErrors()));
}
}
@Override
public void onFailure(Throwable t) {
- LOG.error("Meter remove failed for id={}. Exception {}",input.getMeterId(),t);
+ LOG.error("Service call for meter remove failed for id={}. Exception {}",input.getMeterId(),t);
}
});
return nodePath.augmentation(FlowCapableNode.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter.class, new MeterKey(meterId));
}
+ private final String errorsToString(final Collection<RpcError> rpcErrors) {
+ final StringBuilder errors = new StringBuilder();
+ if ((null != rpcErrors) && (rpcErrors.size() > 0)) {
+ for (final RpcError rpcError : rpcErrors) {
+ errors.append(rpcError.getMessage());
+ }
+ }
+ return errors.toString();
+ }
}