import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+@Singleton
public class ItmManagerRpcService implements ItmRpcService {
private static final Logger LOG = LoggerFactory.getLogger(ItmManagerRpcService.class);
- DataBroker dataBroker;
- private IMdsalApiManager mdsalManager;
-
+ private final DataBroker dataBroker;
+ private final IMdsalApiManager mdsalManager;
+ private final IdManagerService idManagerService;
- public void setMdsalManager(IMdsalApiManager mdsalManager) {
- this.mdsalManager = mdsalManager;
+ @Inject
+ public ItmManagerRpcService(final DataBroker dataBroker,final IdManagerService idManagerService,
+ final IMdsalApiManager iMdsalApiManager) {
+ this.dataBroker = dataBroker;
+ this.idManagerService = idManagerService;
+ this.mdsalManager = iMdsalApiManager;
}
- IdManagerService idManagerService;
+ @PostConstruct
+ public void start() throws Exception {
+ LOG.info("ItmManagerRpcService Started");
+ }
- public ItmManagerRpcService(DataBroker dataBroker, IdManagerService idManagerService) {
- this.dataBroker = dataBroker;
- this.idManagerService = idManagerService;
+ @PreDestroy
+ public void close() throws Exception {
+ LOG.info("ItmManagerRpcService Closed");
}
@Override
}
@Override public void onFailure(Throwable error) {
- String msg = String.format("Unable to delete DcGatewayIp {} in datastore "+ input.getDestinationIp() + "and tunnel type " + input.getTunnelType());
- LOG.error("Unable to delete DcGatewayIp {} in datastore for ip "+ input.getDestinationIp() + "and tunnel type " + input.getTunnelType());
+ String msg =
+ "Unable to delete DcGatewayIp " + input.getDestinationIp() + " in datastore and tunnel type " + input.getTunnelType();
+ LOG.error(msg);
result.set(RpcResultBuilder.<Void>failed()
.withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
@Override
public void onFailure(Throwable error) {
- String msg = String.format("Unable to create ext tunnel");
+ String msg = "Unable to create ext tunnel";
LOG.error("create ext tunnel failed. {}. {}", msg, error);
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
}
@Override public void onFailure(Throwable error) {
- String msg = String.format("Unable to create DcGatewayIp {} in datastore for ip "+ input.getDestinationIp() + "and tunnel type " + input.getTunnelType());
- LOG.error("Unable to create DcGatewayIp {} in datastore for ip "+ input.getDestinationIp() + "and tunnel type " + input.getTunnelType());
+ String msg =
+ "Unable to create DcGatewayIp {} in datastore for ip "+ input.getDestinationIp() + "and tunnel type " + input.getTunnelType();
+ LOG.error(msg);
result.set(RpcResultBuilder.<Void>failed()
.withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
}
private String getFlowRef(long termSvcTable, int svcId) {
- return new StringBuffer().append(termSvcTable).append(svcId).toString();
+ return String.valueOf(termSvcTable) + svcId;
}
@Override
return result;
}
- if(foundVxlanTzone == false)
+ if (!foundVxlanTzone) {
result.set(RpcResultBuilder.<Void>failed()
.withError(RpcError.ErrorType.APPLICATION, "No VxLan TransportZones configured")
.build());
+ }
return result;
} catch (Exception e) {
for (TransportZone tzone : tZones.getTransportZone()) {
if (!(tzone.getTunnelType().equals(TunnelTypeVxlan.class)))
continue;
- foundVxlanTzone = true;
String transportZone = tzone.getZoneName();
if (tzone.getSubnets() == null || tzone.getSubnets().isEmpty()) {
- result.set(RpcResultBuilder.<Void>failed()
- .withError(RpcError.ErrorType.APPLICATION, "No subnets Configured").build());
- return result;
+ continue;
}
+ foundVxlanTzone = true;
SubnetsKey subnetsKey = tzone.getSubnets().get(0).getKey();
DeviceVtepsKey deviceVtepKey = new DeviceVtepsKey(hwIp, node_id);
InstanceIdentifier<DeviceVteps> path = InstanceIdentifier.builder(TransportZones.class)
return result;
}
- if(foundVxlanTzone == false)
+ if (!foundVxlanTzone) {
result.set(RpcResultBuilder.<Void>failed()
.withError(RpcError.ErrorType.APPLICATION, "No VxLan TransportZones configured")
.build());
+ }
return result;
} catch (Exception e) {