Object eventSource = event.getSource();
if(!(eventSource instanceof ProvisionMonitor)) {
peerLogger.debug("ProvisionMonitorPeer: unknown event source : {}", eventSource.getClass().getName());
return;
}
ProvisionMonitor remoteMonitor = (ProvisionMonitor)eventSource;
String opStringName = null;
OpStringManager opMgr;
ProvisionMonitorEvent pme = (ProvisionMonitorEvent)event;
OperationalString opString = pme.getOperationalString();
ServiceElement sElem = pme.getServiceElement();
ProvisionMonitorEvent.Action action = pme.getAction();
switch(action) {
case SERVICE_ELEMENT_UPDATED:
case SERVICE_BEAN_INCREMENTED:
case SERVICE_BEAN_DECREMENTED:
String sAction = action.toString();
if(sElem == null) {
peerLogger.debug("ProvisionMonitorPeer: {} sElem is null", sAction);
return;
}
opStringName = sElem.getOperationalStringName();
peerLogger.trace("ProvisionMonitorPeer: {}, opstring: {}", sAction, opStringName);
opMgr = opStringMangerController.getOpStringManager(opStringName);
if(opMgr == null) {
peerLogger.debug("ProvisionMonitorPeer: {} opstring [{}] not found", sAction, opStringName);
return;
}
try {
opMgr.doUpdateServiceElement(sElem);
} catch(Exception e) {
peerLogger.warn("Updating OperationalStringManager's ServiceElement", e);
}
break;
case SERVICE_ELEMENT_ADDED:
if(sElem == null) {
peerLogger.warn("ProvisionMonitorPeer: SERVICE_ELEMENT_ADDED sElem is null");
return;
}
opStringName = sElem.getOperationalStringName();
peerLogger.trace("ProvisionMonitorPeer: SERVICE_ELEMENT_ADDED, opstring: {}", opStringName);
opMgr = opStringMangerController.getOpStringManager(opStringName);
if(opMgr == null) {
peerLogger.debug("ProvisionMonitorPeer: SERVICE_ELEMENT_ADDED opstring [{}] not found" ,opStringName);
return;
}
try {
opMgr.doAddServiceElement(sElem, null);
} catch(Exception e) {
peerLogger.warn("Adding ServiceElement to OperationalStringManager", e);
}
break;
case SERVICE_ELEMENT_REMOVED:
if(sElem == null) {
peerLogger.debug("ProvisionMonitorPeer: SERVICE_ELEMENT_REMOVED sElem is null");
return;
}
opStringName = sElem.getOperationalStringName();
peerLogger.trace("ProvisionMonitorPeer: SERVICE_ELEMENT_REMOVED, opstring: {}", opStringName);
opMgr = opStringMangerController.getOpStringManager(opStringName);
if(opMgr == null) {
peerLogger.debug("ProvisionMonitorPeer: SERVICE_ELEMENT_REMOVED opstring [{}] not found",
opStringName);
return;
}
try {
opMgr.doRemoveServiceElement(sElem, false);
} catch(Exception e) {
peerLogger.warn("Removing ServiceElement from OperationalStringManager", e);
}
break;
case OPSTRING_DEPLOYED:
if(opString == null) {
peerLogger.warn("ProvisionMonitorPeer: OPSTRING_DEPLOYED opstring is null");
return;
}
DeployAdmin deployAdmin = (DeployAdmin)remoteMonitor.getAdmin();
opStringProcessor(opString, remoteMonitor, deployAdmin, pme.getRemoteRepositories());
peerLogger.trace("ProvisionMonitorPeer: OPSTRING_DEPLOYED, opstring: {}", opString.getName());
break;
case OPSTRING_UNDEPLOYED:
if(opString == null) {
peerLogger.debug("ProvisionMonitorPeer: OPSTRING_UNDEPLOYED opstring is null");
return;
}
peerLogger.trace("ProvisionMonitorPeer: OPSTRING_UNDEPLOYED, opstring: {}", opString.getName());
opMgr = opStringMangerController.getOpStringManager(opString.getName());
if(opMgr == null) {
peerLogger.debug("ProvisionMonitorPeer: OPSTRING_UNDEPLOYED for opstring [{}] not found",
opString.getName());
return;
}
opMgr.setDeploymentStatus(OperationalString.UNDEPLOYED);
opMgr.terminate(false);
synchronized(opStringTable) {
if(opStringTable.containsKey(remoteMonitor)) {
List<OpStringManager> list = opStringTable.get(remoteMonitor);
list.remove(opMgr);
opStringTable.put(remoteMonitor, list);
}
}
break;
case OPSTRING_MGR_CHANGED:
if(opString == null) {
peerLogger.debug("ProvisionMonitorPeer: OPSTRING_MGR_CHANGED opstring is null");
return;
}
peerLogger.debug("ProvisionMonitorPeer: OPSTRING_MGR_CHANGED, opstring: {}", opString.getName());
opMgr = opStringMangerController.getOpStringManager(opString.getName());
if(opMgr == null) {
peerLogger.debug("ProvisionMonitorPeer: OPSTRING_MGR_CHANGED opstring [{}] not found",
opString.getName());
return;
}
synchronized(opStringTable) {
List<OpStringManager> list;
if(opStringTable.containsKey(remoteMonitor))
list = opStringTable.get(remoteMonitor);
else
list = new ArrayList<OpStringManager>();
if(!list.contains(opMgr)) {
list.add(opMgr);
opStringTable.put(remoteMonitor, list);
peerLogger.debug("ProvisionMonitorPeer: Reset backup peer for [{}] to {}",
opString.getName(), remoteMonitor.toString());
} else {
peerLogger.debug("ProvisionMonitorPeer: Already a backup for [{}] to {}",
opString.getName(), remoteMonitor.toString());
}
}
break;
case OPSTRING_UPDATED:
if(opString == null) {