public boolean isPast(long date) { return currentTimeMillis() > date; }
public boolean isFuture(long date) { return currentTimeMillis() < date; }
public XMLGregorianCalendar currentTimeXMLGregorianCalendar() { long millis = currentTimeMillis(); return XmlTypeConverter.createXMLGregorianCalendar(millis); }
private void recordFatalError(Exception e, XMLGregorianCalendar projectoStartTimestampCal, OperationResult result) { result.recordFatalError(e); result.cleanupResult(e); if (LOGGER.isDebugEnabled()) { long projectoStartTimestamp = XmlTypeConverter.toMillis(projectoStartTimestampCal); long projectorEndTimestamp = clock.currentTimeMillis(); LOGGER.debug("Projector failed: {}. Etime: {} ms", e.getMessage(), (projectorEndTimestamp - projectoStartTimestamp)); } }
public synchronized void registerCounter(Task task, boolean timeCounter) { CounterSepcification counterSpec = countersMap.get(task.getOid()); if (counterSpec == null) { counterSpec = new CounterSepcification(); counterSpec.setCounterStart(clock.currentTimeMillis()); countersMap.put(task.getOid(), counterSpec); return; } if (timeCounter) { long currentInMillis = clock.currentTimeMillis(); long start = counterSpec.getCounterStart(); if (start + 3600 * 1000 < currentInMillis) { counterSpec = new CounterSepcification(); counterSpec.setCounterStart(clock.currentTimeMillis()); countersMap.replace(task.getOid(), counterSpec); } return; } counterSpec = new CounterSepcification(); counterSpec.setCounterStart(clock.currentTimeMillis()); countersMap.replace(task.getOid(), counterSpec); }
/** * Extends offset on top of existing offset. */ public void overrideDuration(Duration duration) { long millis = currentTimeMillis(); XMLGregorianCalendar time = XmlTypeConverter.createXMLGregorianCalendar(millis); time.add(duration); long offset = XmlTypeConverter.toMillis(time) - millis; overrideDuration(offset); }
private boolean isCachedShadowValid(Collection<SelectorOptions<GetOperationOptions>> options, PrismObject<ShadowType> repositoryShadow, ResourceType resource) throws ConfigurationException { long stalenessOption = GetOperationOptions.getStaleness(SelectorOptions.findRootOptions(options)); if (stalenessOption == 0L) { return false; } CachingMetadataType cachingMetadata = repositoryShadow.asObjectable().getCachingMetadata(); if (cachingMetadata == null) { if (stalenessOption == Long.MAX_VALUE) { // We must return cached version but there is no cached version. throw new ConfigurationException("Cached version of "+repositoryShadow+" requested, but there is no cached value"); } return false; } if (stalenessOption == Long.MAX_VALUE) { return true; } XMLGregorianCalendar retrievalTimestamp = cachingMetadata.getRetrievalTimestamp(); if (retrievalTimestamp == null) { return false; } long retrievalTimestampMillis = XmlTypeConverter.toMillis(retrievalTimestamp); return (clock.currentTimeMillis() - retrievalTimestampMillis < stalenessOption); }
if (LOGGER.isDebugEnabled()) { long projectoStartTimestamp = XmlTypeConverter.toMillis(projectoStartTimestampCal); long projectorEndTimestamp = clock.currentTimeMillis(); LOGGER.trace("Projector finished ({}). Etime: {} ms", result.getStatus(), (projectorEndTimestamp - projectoStartTimestamp));
@Test public void test217ModifyLargoRemoveValidFrom() throws Exception { final String TEST_NAME = "test217ModifyLargoRemoveValidFrom"; displayTestTitle(TEST_NAME); // GIVEN long startMillis = clock.currentTimeMillis(); Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN modifyUserReplace(USER_LARGO_OID, ACTIVATION_VALID_FROM_PATH, task, result); // THEN PrismObject<UserType> userLargo = getUser(USER_LARGO_OID); display("User after change execution", userLargo); assertValidity(userLargo, null); assertValidityTimestamp(userLargo, startMillis, clock.currentTimeMillis()); lastValidityChangeTimestamp = userLargo.asObjectable().getActivation().getValidityChangeTimestamp(); assertEffectiveStatus(userLargo, ActivationStatusType.ENABLED); assertUser(userLargo, USER_LARGO_OID, USER_LARGO_USERNAME, "Largo LaGrande", "Largo", "LaGrande"); accountOid = getSingleLinkOid(userLargo); // Check shadow PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result); assertDummyAccountShadowRepo(accountShadow, accountOid, USER_LARGO_USERNAME); // Check account PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result); assertDummyAccountShadowModel(accountModel, accountOid, USER_LARGO_USERNAME, "Largo LaGrande"); // Check account in dummy resource assertDefaultDummyAccount(USER_LARGO_USERNAME, "Largo LaGrande", true); }
@Test public void test215ModifyLargoRemoveValidTo() throws Exception { final String TEST_NAME = "test215ModifyLargoRemoveValidTo"; displayTestTitle(TEST_NAME); // GIVEN long startMillis = clock.currentTimeMillis(); Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN modifyUserDelete(USER_LARGO_OID, ACTIVATION_VALID_TO_PATH, task, result, manana); // THEN PrismObject<UserType> userLargo = getUser(USER_LARGO_OID); display("User after change execution", userLargo); assertValidity(userLargo, TimeIntervalStatusType.IN); assertValidityTimestamp(userLargo, startMillis, clock.currentTimeMillis()); lastValidityChangeTimestamp = userLargo.asObjectable().getActivation().getValidityChangeTimestamp(); assertEffectiveStatus(userLargo, ActivationStatusType.ENABLED); assertUser(userLargo, USER_LARGO_OID, USER_LARGO_USERNAME, "Largo LaGrande", "Largo", "LaGrande"); accountOid = getSingleLinkOid(userLargo); // Check shadow PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result); assertDummyAccountShadowRepo(accountShadow, accountOid, USER_LARGO_USERNAME); // Check account PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result); assertDummyAccountShadowModel(accountModel, accountOid, USER_LARGO_USERNAME, "Largo LaGrande"); // Check account in dummy resource assertDefaultDummyAccount(USER_LARGO_USERNAME, "Largo LaGrande", true); }
long reconStartTimestamp = clock.currentTimeMillis(); long beforeResourceReconTimestamp = clock.currentTimeMillis(); long afterResourceReconTimestamp; long afterShadowReconTimestamp; return runResult; afterResourceReconTimestamp = clock.currentTimeMillis(); if (isStage(stage, Stage.THIRD) && !performShadowReconciliation(resource, objectclassDef, reconStartTimestamp, afterResourceReconTimestamp, reconResult, localCoordinatorTask, workBucket, opResult)) { return runResult; afterShadowReconTimestamp = clock.currentTimeMillis(); } catch (ObjectNotFoundException ex) { auditService.audit(executionRecord, localCoordinatorTask); long reconEndTimestamp = clock.currentTimeMillis();
display("campaign in stage 1", campaign); assertSanityAfterCampaignStart(campaign, certificationDefinition, 7, 3, 3, new Date(clock.currentTimeMillis())); List<AccessCertificationCaseType> caseList = campaign.getCase();
XMLGregorianCalendar hourAhead = XmlTypeConverter.createXMLGregorianCalendar(clock.currentTimeMillis() + 60 * 60 * 1000);
display("campaign in stage 1", campaign); assertSanityAfterCampaignStart(campaign, certificationDefinition, 7, 2, 2, new Date(clock.currentTimeMillis())); List<AccessCertificationCaseType> caseList = campaign.getCase();
XMLGregorianCalendar hourAgo = XmlTypeConverter.createXMLGregorianCalendar(clock.currentTimeMillis() - 60 * 60 * 1000);
continue; long diff = XmlTypeConverter.toMillis(trigger.getTimestamp()) - clock.currentTimeMillis(); if (diff >= COMPLETION_TRIGGER_EQUALITY_THRESHOLD) { continue;