/** * Mark the specified action as completed * * @param transactionId the unique transaction id for this action * @param scheduledActionUuid the unique name of an action */ private void markAsCompleted(String transactionId, String scheduledActionUuid) { try { Ebean.beginTransaction(); SchedulerState schedulerState = SchedulerState.getRunningSchedulerStateFromTransactionId(transactionId); if (schedulerState == null) { log.error( String.format( "Strange ... No running scheduled action for %s with transaction id %s while one was running and mark as completed is requested", scheduledActionUuid, transactionId)); } else { schedulerState.isRunning = false; schedulerState.save(); if (log.isDebugEnabled()) { log.debug( String.format( "Scheduled action for %s with transaction id %s completed", scheduledActionUuid, transactionId)); } } Ebean.commitTransaction(); } catch (Exception e) { log.error("Failed to mark as complete", e); rollbackTransactionSilent(); } finally { endTransactionSilent(); } }
@Override public void dumpSystemStatus(String eventName, boolean logAsDebug) { if (logAsDebug) { log.debug(eventName + " " + ArrayUtils.toString(getSystemStatus())); } else { log.info(eventName + " " + ArrayUtils.toString(getSystemStatus())); } }
/** * Parses a country code as string. * * @param countryCodeAsString the string representing a country code. * @return the country code represented in the string, or absent if it does not correspond to a * valid country. */ public static Optional<CountryCode> parseCode(String countryCodeAsString) { try { return Optional.of(CountryCode.valueOf(countryCodeAsString)); } catch (IllegalArgumentException e) { LOGGER.debug("Invalid country " + countryCodeAsString); return Optional.empty(); } }
@SecuredAction public WebSocket<String> getSocket() { // User player = (User) ctx().args.get(SecureSocial.USER_KEY); User player = (User) SecureSocial.currentUser(env).get(100); logger.debug("[LobbyController:getSocket] getSocket called from User: "******"[LobbyController:getSocket] ...player found! Returning WebSocket for this player"); return lobbys.get(lobbyName).getSocketForPlayer(player); } } } logger.debug( "[LobbyController:getSocket] ...player not found. Player didn't joined a lobby. Rejecting WebSocket."); return WebSocket.reject(Results.badRequest("Player didn't joined a game.")); }
private void removeEmptyLobbys() { for (Entry<String, Lobby> entry : lobbys.entrySet()) { logger.debug( "[LobbyController:play] Lobby: " + entry.getKey() + " count players: " + entry.getValue().getPlayerCount()); if (entry.getValue().getPlayerCount() == 0) { lobbys.remove(entry.getKey()); } } }
private static Optional<JsonNode> getValidJson(Http.RequestBody body) { JsonNode json = body.asJson(); logger.debug("received json: {}", json); try { // validates json Json.fromJson(json, Message.class); } catch (Exception e) { logger.warn("Invalid json ({})", e.getCause().getMessage()); return Optional.empty(); } return Optional.of(json); }
/** * Accepts a JSON message and publishes it on the {@link services.RedisAccess#CHANNEL_MESSAGES} * pub/sub channel * */ public Result message() { Optional<JsonNode> json = getValidJson(request().body()); if (!json.isPresent()) { return badRequest(); } redisAccess.run( jedis -> { Long subscribers = jedis.publish(CHANNEL_MESSAGES, json.get().toString()); logger.debug("message published to {} subscribers", subscribers); }); return ok(); }
@SecuredAction public Result play(String lobbyName) { logger.debug("[LobbyController:play] Play function called"); if (lobbyName.equals("")) { lobbyName = DEFAULT_LOBBY_NAME; } User player = (User) ctx().args.get(SecureSocial.USER_KEY); synchronized (lobbys) { // Check if Player is already in other lobby for (Entry<String, Lobby> entry : lobbys.entrySet()) { if (entry.getValue().containsPlayer(player) && !(entry.getKey().equals(lobbyName))) { entry.getValue().removePlayer(player); } } logger.debug("[LobbyController:play] All lobbys: " + lobbys.toString()); // Remove empty lobbys removeEmptyLobbys(); if (!lobbys.containsKey(lobbyName)) { // Lobby does not exist logger.debug( "[LobbyController:play] Lobby '" + lobbyName + "' does not exist. Creating new one."); lobbys.put(lobbyName, new Lobby(lobbyName)); logger.debug("[LobbyController:play] Adding player to lobby '" + lobbyName + "'"); ; lobbys.get(lobbyName).addPlayer(player); } else { // Player is not already in Lobby if (!lobbys.get(lobbyName).containsPlayer(player)) { logger.debug( "[LobbyController:play] Lobby '" + lobbyName + "' exists but player is not in lobby."); ; if (lobbys.get(lobbyName).gameStarted()) { logger.debug( "[LobbyController:play] Lobby '" + lobbyName + "' has already started game"); ; } else { logger.debug("[LobbyController:play] Adding player to lobby '" + lobbyName + "'"); ; lobbys.get(lobbyName).addPlayer(player); } } } } return ok(pokerGame.render(player, SecureSocial.env(), lobbyName)); }
@Override public Cancellable scheduleRecurring( final boolean exclusive, final String scheduledActionUuid, FiniteDuration initialDelay, FiniteDuration interval, final Runnable runnable, final boolean logInDebug) { if (log.isDebugEnabled()) { log.debug("Request " + (exclusive ? "EXCLUSIVE" : "STANDARD") + " " + scheduledActionUuid); } return getActorSystem() .scheduler() .schedule( initialDelay, interval, new Runnable() { @Override public void run() { String transactionId = Utilities.getRandomID(); dumpSystemStatus( "SCHEDULER START for " + scheduledActionUuid + " [" + (exclusive ? "EXCLUSIVE" : "STANDARD") + "] and transaction " + transactionId, logInDebug); markAsStarted(transactionId, scheduledActionUuid); try { runnable.run(); } catch (Exception e) { log.error( "The job " + scheduledActionUuid + " raised an exception within the transaction " + transactionId, e); } markAsCompleted(transactionId, scheduledActionUuid); dumpSystemStatus( "SCHEDULER STOP for " + scheduledActionUuid + " and transaction " + transactionId, logInDebug); } }, getActorSystem().dispatcher()); }
/** * Mark the specified action as completed * * @param transactionId the unique transaction id for this action * @param scheduledActionUuid the unique name of an action */ private void markAsStarted(String transactionId, String scheduledActionUuid) { try { Ebean.beginTransaction(); SchedulerState schedulerState = new SchedulerState(); schedulerState.actionUuid = scheduledActionUuid; schedulerState.transactionId = transactionId; schedulerState.isRunning = true; schedulerState.save(); if (log.isDebugEnabled()) { log.debug( String.format( "Scheduled action for %s with transaction id %s started", scheduledActionUuid, transactionId)); } Ebean.commitTransaction(); } catch (Exception e) { log.error("Failed to mark as started", e); rollbackTransactionSilent(); } finally { endTransactionSilent(); } }
public void run_NeolixOrder(ImportNeolixVO vo) { String sql = "{CALL run_NeolixOrder('" + vo.orderNum + "','" + vo.datePay + "','" + vo.mechantNum + "'," + vo.counts + ",'" + vo.receiver + "','" + vo.parentsAddress + "','" + vo.subAddress + "','" + vo.phone + "','','" + vo.totalFee + "','" + vo.price + "','" + vo.expenses + "','" + vo.dateOrder + "')}"; // SQL语句 //调用存储过程 logger.debug(sql); JdbcOper db = JdbcOper.getInstance(); // 创建DBHelper对象 try { db.getPrepareStateDao(sql); db.pst.executeQuery(); // 执行语句,得到结果集 } catch (Exception e) { e.printStackTrace(); } finally { db.close(); } }
public WSRequest url(String... urlParts) { String url = Paths.combineToUrl(urlParts); logger.debug("WSClient request to url=[{}]", url); return url(url); }