List of usage examples for org.joda.time DateTime now
public static DateTime now()
ISOChronology
in the default time zone. From source file:com.google.gerrit.server.config.ScheduleConfig.java
License:Apache License
public ScheduleConfig(Config rc, String section, String subsection, String keyInterval, String keyStartTime) { this(rc, section, subsection, keyInterval, keyStartTime, DateTime.now()); }
From source file:com.graphaware.module.timetree.domain.TimeInstant.java
License:Open Source License
/** * Create a new time instant representing now in UTC timezone with {@link Resolution#DAY}. * * @return time instant representing now. *//* ww w .j a v a 2s. com*/ public static TimeInstant now() { return instant(DateTime.now().getMillis()); }
From source file:com.greenline.hrs.admin.cache.redis.util.RedisInfoParser.java
License:Open Source License
/** * RedisInfoMapT?RedisInfoMapRedis?/*from ww w .j a va 2 s.com*/ * * @param redisInfoMap Map * @return instanceTypeinfomapnullinfoMap?instancenullRedisServerInfoPO */ public static List<RedisKeyspaceInfo> parserToKeySpaceInfo(Map<String, String> redisInfoMap) { if (redisInfoMap == null || redisInfoMap.isEmpty()) { return Collections.EMPTY_LIST; } int dbSize = 16; String dbSizeStr = redisInfoMap.get(RedisCommonConst.DB_SIZE); if (StringUtils.isNumeric(dbSizeStr)) { dbSize = Integer.valueOf(dbSizeStr); } List<RedisKeyspaceInfo> result = new ArrayList<RedisKeyspaceInfo>(dbSize * 2); for (int i = 0; i < dbSize; i++) { RedisKeyspaceInfo keyspaceInfo = new RedisKeyspaceInfo(); // TODO createTime?? keyspaceInfo.setCreateTime(DateTime.now().toDate()); keyspaceInfo.setDbIndex(i); keyspaceInfo.setKeys(0L); keyspaceInfo.setExpires(0L); String keyspaceStr = redisInfoMap.get("db" + i); if (keyspaceStr != null) { String[] properties = StringUtils.split(keyspaceStr, KS_PROPERTY_DELIMITER); if (properties.length >= KS_PROPERTY_MIN_SIZE) { keyspaceInfo.setKeys(Long.valueOf(properties[1])); keyspaceInfo.setExpires(Long.valueOf(properties[3])); result.add(keyspaceInfo); } } } return result; }
From source file:com.groupon.deployment.fleet.Sequential.java
License:Apache License
@Override public void onReceive(final Object message) throws Exception { if ("start".equals(message)) { _current = _hostQueue.poll();// www .ja v a 2 s. co m log("Deployment starting", null); startCurrent(); } else if (message instanceof HostDeploymentNotifications.DeploymentSucceeded) { _deployment.heartbeat(); // Only update if the host is the currently deploying host final HostDeploymentNotifications.DeploymentSucceeded succeeded = (HostDeploymentNotifications.DeploymentSucceeded) message; if (!_current.getHost().getName().equals(succeeded.getHost().getName())) { Logger.warn(String.format( "Received a host deployment succeeded message from unexpected host; expected=%s, actual=%s", _current.getHost().getName(), succeeded.getHost().getName())); } else { _current.setState(DeploymentState.SUCCEEDED); _current.setFinished(DateTime.now()); _current.save(); _current = _hostQueue.poll(); startCurrent(); } } else if (message instanceof HostDeploymentNotifications.DeploymentStarted) { _deployment.heartbeat(); final HostDeploymentNotifications.DeploymentStarted started = (HostDeploymentNotifications.DeploymentStarted) message; if (!_current.getHost().getName().equals(started.getHost().getName())) { Logger.warn(String.format( "Received a host deployment started message from unexpected host; expected=%s, actual=%s", _current.getHost().getName(), started.getHost().getName())); } else { log("Deployment started for host; host=" + started.getHost().getName(), started.getHost()); _current.setState(DeploymentState.RUNNING); _current.save(); } } else if (message instanceof HostDeploymentNotifications.DeploymentFailed) { final HostDeploymentNotifications.DeploymentFailed failed = (HostDeploymentNotifications.DeploymentFailed) message; processHostDeploymentFailedMessage(failed); } else if (message instanceof HostDeploymentNotifications.DeploymentLog) { final HostDeploymentNotifications.DeploymentLog log = (HostDeploymentNotifications.DeploymentLog) message; log(log.getLog(), log.getHost()); } else { unhandled(message); } }
From source file:com.groupon.deployment.fleet.Sequential.java
License:Apache License
private void processHostDeploymentFailedMessage(final HostDeploymentNotifications.DeploymentFailed failed) { _deployment.heartbeat();// w w w . j a v a 2 s. c o m if (!_current.getHost().getName().equals(failed.getHost().getName())) { Logger.warn(String.format( "Received a host deployment failed message from unexpected host; expected=%s, actual=%s", _current.getHost().getName(), failed.getHost().getName())); } else { _current.setState(DeploymentState.FAILED); _current.setFinished(DateTime.now()); _current.save(); } _deployment.setState(DeploymentState.FAILED); _deployment.setFinished(DateTime.now()); _deployment.save(); log("Deployment has failed; cause=" + failed.getFailure(), failed.getFailure(), failed.getHost()); self().tell(PoisonPill.getInstance(), self()); }
From source file:com.groupon.deployment.fleet.Sequential.java
License:Apache License
private void startCurrent() { if (_current == null) { _deployment.setFinished(DateTime.now()); _deployment.setState(DeploymentState.SUCCEEDED); _deployment.save();/*from www. j a va 2 s. com*/ final String message = "Deployment completed successfully"; log(message, null); self().tell(PoisonPill.getInstance(), self()); } else { final String myName; try { myName = InetAddress.getLocalHost().getCanonicalHostName(); } catch (final UnknownHostException e) { throw Throwables.propagate(e); } // If the host is ourselves, then set the owner to null and wait for someone else to take over if (myName.equals(_current.getHost().getName())) { Logger.info("Found myself as the deploy target. Turning over control."); _deployment.refresh(); _deployment.setDeploymentOwner(null); _deployment.save(); self().tell(PoisonPill.getInstance(), self()); return; } final ManifestHistory manifestHistory = _deployment.getManifestHistory(); final EnvironmentType environmentType = manifestHistory.getStage().getEnvironment() .getEnvironmentType(); if (environmentType.equals(EnvironmentType.ROLLER)) { final String actorName = "rollerDeploy-" + _current.getHost().getId(); context().actorOf( Props.create(Roller.class, () -> _hostDeploymentFactory.createRoller(_current.getHost())), actorName); } else if (environmentType.equals(EnvironmentType.DOCKER)) { final String actorName = "dockerDeploy-" + _current.getHost().getId(); final ActorRef dockerDeployActor = context().actorOf( Props.create(Docker.class, () -> _hostDeploymentFactory.createDocker( _dcf.createDockerClient(_sshFactory.create(_current.getHost().getName())))), actorName); dockerDeployActor.tell(new HostDeploymentCommands.StartDeployment(manifestHistory.getManifest(), _current.getHost(), manifestHistory.getStage()), self()); } } }
From source file:com.groupon.deployment.fleet.Sequential.java
License:Apache License
private void log(final String message, final Host host) { final DeploymentLog logRecord = new DeploymentLog(); logRecord.setDeployment(_deployment); logRecord.setHost(host);/*from w ww. j a v a 2 s . co m*/ logRecord.setLogTime(DateTime.now()); logRecord.setMessage(message); logRecord.save(); }
From source file:com.gst.commands.domain.CommandSource.java
License:Apache License
public static CommandSource fullEntryFrom(final CommandWrapper wrapper, final JsonCommand command, final AppUser maker) { return new CommandSource(wrapper.actionName(), wrapper.entityName(), wrapper.getHref(), command.entityId(), command.subentityId(), command.json(), maker, DateTime.now()); }
From source file:com.gst.commands.service.PortfolioCommandSourceWritePlatformServiceImpl.java
License:Apache License
@Override public Long rejectEntry(final Long makerCheckerId) { final CommandSource commandSourceInput = validateMakerCheckerTransaction(makerCheckerId); validateIsUpdateAllowed();//from w ww . j a va2 s .c om final AppUser maker = this.context.authenticatedUser(); commandSourceInput.markAsRejected(maker, DateTime.now()); this.commandSourceRepository.save(commandSourceInput); return makerCheckerId; }
From source file:com.gst.commands.service.SynchronousCommandProcessingService.java
License:Apache License
@Transactional @Override/*from w ww. j ava2 s . c o m*/ public CommandProcessingResult processAndLogCommand(final CommandWrapper wrapper, final JsonCommand command, final boolean isApprovedByChecker) { final boolean rollbackTransaction = this.configurationDomainService .isMakerCheckerEnabledForTask(wrapper.taskPermissionName()); final NewCommandSourceHandler handler = findCommandHandler(wrapper); final CommandProcessingResult result = handler.processCommand(command); final AppUser maker = this.context.authenticatedUser(wrapper); CommandSource commandSourceResult = null; if (command.commandId() != null) { commandSourceResult = this.commandSourceRepository.findOne(command.commandId()); commandSourceResult.markAsChecked(maker, DateTime.now()); } else { commandSourceResult = CommandSource.fullEntryFrom(wrapper, command, maker); } commandSourceResult.updateResourceId(result.resourceId()); commandSourceResult.updateForAudit(result.getOfficeId(), result.getGroupId(), result.getClientId(), result.getLoanId(), result.getSavingsId(), result.getProductId(), result.getTransactionId()); String changesOnlyJson = null; if (result.hasChanges()) { changesOnlyJson = this.toApiJsonSerializer.serializeResult(result.getChanges()); commandSourceResult.updateJsonTo(changesOnlyJson); } if (!result.hasChanges() && wrapper.isUpdateOperation() && !wrapper.isUpdateDatatable()) { commandSourceResult.updateJsonTo(null); } if (commandSourceResult.hasJson()) { this.commandSourceRepository.save(commandSourceResult); } if ((rollbackTransaction || result.isRollbackTransaction()) && !isApprovedByChecker) { /* * JournalEntry will generate a new transactionId every time. * Updating the transactionId with old transactionId, because as * there are no entries are created with new transactionId, will * throw an error when checker approves the transaction */ commandSourceResult.updateTransaction(command.getTransactionId()); /* * Update CommandSource json data with JsonCommand json data, line * 77 and 81 may update the json data */ commandSourceResult.updateJsonTo(command.json()); throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(commandSourceResult); } result.setRollbackTransaction(null); publishEvent(wrapper.entityName(), wrapper.actionName(), result); return result; }