use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class ClusterEventBus method serveMessage.
void serveMessage(Message message, long receiveEnqueueTime) {
// stats
final long receiveTime = System.currentTimeMillis();
if (receiveEnqueueTime > 0) {
final long diff = receiveTime - receiveEnqueueTime;
mrtgProbeJMSEnqueueTime_.addMeasurement(diff);
}
if (lastOnMessageFinishTime_ != -1) {
final long waitingTime = receiveTime - lastOnMessageFinishTime_;
// the waiting time is inverted to represent more like a frequency
// the values it translates to are the following:
// 0ms -> 100
// 1ms -> 66
// 2ms -> 50
// 4ms -> 33
// 6ms -> 25
// 8ms -> 20
// 18ms -> 10
// 20ms -> 9
// 23ms -> 8
// 26.5ms -> 7
// 31ms -> 6
// 38ms -> 5
mrtgProbeJMSLoad_.addMeasurement((long) (100.0 / ((waitingTime / 2.0) + 1.0)));
lastOnMessageFinishTime_ = -1;
}
ObjectMessage om = (ObjectMessage) message;
try {
// unpack
JMSWrapper jmsWrapper = (JMSWrapper) om.getObject();
Integer nodeId = jmsWrapper.getNodeId();
MultiUserEvent event = jmsWrapper.getMultiUserEvent();
OLATResourceable ores = jmsWrapper.getOres();
boolean fromSameNode = clusterConfig.getNodeId().equals(nodeId);
String recMsg = "received msg: " + (fromSameNode ? "[same node]" : "") + " from node:" + nodeId + ", olat-id:" + jmsWrapper.getMsgId() + ", ores:" + ores.getResourceableTypeName() + ":" + ores.getResourceableId() + ", event:" + event + "}";
// stats
final long jmsTimestamp = om.getJMSTimestamp();
if (jmsTimestamp != 0) {
final long deliveryTime = receiveTime - jmsTimestamp;
if (deliveryTime > 1500) {
// then issue a log statement
log.warn("message received with long delivery time (longer than 1500ms: " + deliveryTime + "): " + recMsg);
}
mrtgProbeJMSDeliveryTime_.addMeasurement(deliveryTime);
}
addToReceivedScreen(recMsg);
if (log.isDebug())
log.debug(recMsg);
// message with destination and source both having this vm are ignored here, since they were already
// "inline routed" when having been sent (direct call within the vm).
// TODO jms if (!fromSameNode) {
// distribute the unmarshalled event to all JVM wide listeners for this channel.
doFire(event, ores);
// TODO jms } // else message already sent "in-vm"
// stats
final long doneTime = System.currentTimeMillis();
final long processingTime = doneTime - receiveTime;
if (processingTime > 500) {
// then issue a log statement
log.warn("message received with long processing time (longer than 500ms: " + processingTime + "): " + recMsg);
}
mrtgProbeJMSProcessingTime_.addMeasurement(processingTime);
} catch (Error er) {
log.error("Uncaught Error in ClusterEventBus.onMessage!", er);
throw er;
} catch (RuntimeException re) {
log.error("Uncaught RuntimeException in ClusterEventBus.onMessage!", re);
throw re;
} catch (JMSException e) {
log.warn("JMSException in ClusterEventBus.onMessage", e);
throw new OLATRuntimeException("error when receiving jms messages", e);
} catch (Throwable th) {
log.error("Uncaught Throwable in ClusterEventBus.onMessage!", th);
} finally {
lastOnMessageFinishTime_ = System.currentTimeMillis();
}
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class ChecklistManager method deleteChecklist.
/**
* Delete checklist.
* @param checklist
*/
public void deleteChecklist(final Checklist cl) {
final DB db = DBFactory.getInstance();
OLATResourceable ores = OresHelper.createOLATResourceableInstance(Checklist.class, cl.getKey());
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
public void execute() {
Checklist checklist = (Checklist) db.loadObject(cl);
db.deleteObject(checklist);
}
});
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class UserAdminMainController method acquireDeleteUserLock.
/**
* Acquire lock for whole delete-user workflow
*/
private Controller acquireDeleteUserLock(UserRequest ureq) {
OLATResourceable lockResourceable = OresHelper.createOLATResourceableTypeWithoutCheck(TabbedPaneController.class.getName());
lock = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(lockResourceable, ureq.getIdentity(), "deleteGroup");
if (!lock.isSuccess()) {
String fullname = userManager.getUserDisplayName(lock.getOwner());
String text = getTranslator().translate("error.deleteworkflow.locked.by", new String[] { fullname });
Controller monoCtr = MessageUIFactory.createInfoMessage(ureq, getWindowControl(), null, text);
return monoCtr;
}
return null;
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManager method removeFutureOfEvent.
@Override
public boolean removeFutureOfEvent(Kalendar cal, KalendarRecurEvent kalendarEvent) {
OLATResourceable calOres = getOresHelperFor(cal);
Boolean removeSuccessful = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(calOres, new SyncerCallback<Boolean>() {
@Override
public Boolean execute() {
boolean successfullyPersist = false;
try {
String uid = kalendarEvent.getID();
Date occurenceDate = kalendarEvent.getOccurenceDate();
Kalendar loadedCal = getCalendarFromCache(cal.getType(), cal.getCalendarID());
KalendarEvent rootEvent = loadedCal.getEvent(kalendarEvent.getID(), null);
String rRule = rootEvent.getRecurrenceRule();
Recur recur = new Recur(rRule);
recur.setUntil(CalendarUtils.createDate(occurenceDate));
RRule rrule = new RRule(recur);
rootEvent.setRecurrenceRule(rrule.getValue());
for (KalendarEvent kEvent : loadedCal.getEvents()) {
if (uid.equals(kEvent.getID()) && StringHelper.containsNonWhitespace(kEvent.getRecurrenceID()) && occurenceDate.before(kEvent.getBegin())) {
loadedCal.removeEvent(kEvent);
}
}
successfullyPersist = persistCalendar(loadedCal);
} catch (ParseException e) {
log.error("", e);
}
return new Boolean(successfullyPersist);
}
});
// inform all controller about calendar change for reload
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(cal), OresHelper.lookupType(CalendarManager.class));
return removeSuccessful.booleanValue();
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManager method removeEventFrom.
/**
* @see org.olat.commons.calendar.CalendarManager#removeEventFrom(org.olat.commons.calendar.model.Kalendar, org.olat.commons.calendar.model.KalendarEvent)
*/
@Override
public boolean removeEventFrom(final Kalendar cal, final KalendarEvent kalendarEvent) {
OLATResourceable calOres = getOresHelperFor(cal);
Boolean removeSuccessful = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(calOres, new SyncerCallback<Boolean>() {
@Override
public Boolean execute() {
String uid = kalendarEvent.getID();
String recurrenceId = kalendarEvent.getRecurrenceID();
Kalendar loadedCal = getCalendarFromCache(cal.getType(), cal.getCalendarID());
if (StringHelper.containsNonWhitespace(recurrenceId)) {
loadedCal.removeEvent(kalendarEvent);
KalendarEvent rootEvent = loadedCal.getEvent(kalendarEvent.getID(), null);
if (rootEvent != null && kalendarEvent instanceof KalendarRecurEvent) {
Date recurrenceDate = ((KalendarRecurEvent) kalendarEvent).getOccurenceDate();
rootEvent.addRecurrenceExc(recurrenceDate);
}
} else {
for (KalendarEvent kEvent : loadedCal.getEvents()) {
if (uid.equals(kEvent.getID())) {
loadedCal.removeEvent(kEvent);
}
}
}
boolean successfullyPersist = persistCalendar(loadedCal);
return new Boolean(successfullyPersist);
}
});
// inform all controller about calendar change for reload
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(cal), OresHelper.lookupType(CalendarManager.class));
return removeSuccessful.booleanValue();
}
Aggregations