@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt instanceof IdleStateEvent) { IdleStateEvent idleStateEvent = (IdleStateEvent)evt; if (idleStateEvent == IdleStateEvent.READER_IDLE_STATE_EVENT) { if (LOGGER.isInfoEnabled()) { LOGGER.info("RmRpcClient channel" + ctx.channel() + " idle."); } try { nettyClientKeyPool.invalidateObject(poolKeyMap.get(ctx.channel().remoteAddress()), ctx.channel()); } catch (Exception exx) { LOGGER.error(exx.getMessage()); } finally { releaseChannel(ctx.channel(), getAddressFromContext(ctx)); } } if (idleStateEvent == IdleStateEvent.WRITER_IDLE_STATE_EVENT) { try { sendRequest(ctx.channel(), HeartbeatMessage.PING); } catch (Throwable throwable) { LOGGER.error("", "send request error", throwable); } } } }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt instanceof IdleStateEvent) { IdleStateEvent idleStateEvent = (IdleStateEvent)evt; if (idleStateEvent.state() == IdleState.READER_IDLE) { if (LOGGER.isInfoEnabled()) { LOGGER.info("channel" + ctx.channel() + " read idle."); } try { nettyClientKeyPool.invalidateObject(poolKeyMap.get(ctx.channel().remoteAddress()), ctx.channel()); } catch (Exception exx) { LOGGER.error(exx.getMessage()); } finally { releaseChannel(ctx.channel(), getAddressFromContext(ctx)); } } if (idleStateEvent == IdleStateEvent.WRITER_IDLE_STATE_EVENT) { try { if (LOGGER.isInfoEnabled()) { LOGGER.info("will send ping msg,channel" + ctx.channel()); } sendRequest(ctx.channel(), HeartbeatMessage.PING); } catch (Throwable throwable) { LOGGER.error("", "send request error", throwable); } } } }
@Override public void internalWrite(Server server, Query query, ImmutableList<Result> results) throws Exception { Socket socket = null; PrintWriter writer = null; try { socket = pool.borrowObject(address); writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), UTF_8), true); for (String formattedResult : messageFormatter.formatResults(results, server)) { log.debug("OpenTSDB Message: {}", formattedResult); writer.write("put " + formattedResult + "\n"); } } catch (ConnectException e) { log.error("Error while connecting to OpenTSDB", e); } finally { if (writer != null && writer.checkError()) { log.error("Error writing to OpenTSDB, clearing OpenTSDB socket pool"); pool.invalidateObject(address, socket); } else { pool.returnObject(address, socket); } } }
@Override public void internalWrite(Server server, Query query, ImmutableList<Result> results) throws Exception { Socket socket = null; PrintWriter writer = null; try { socket = pool.borrowObject(address); writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), UTF_8), true); List<String> typeNames = this.getTypeNames(); for (Result result : results) { log.debug("Query result: {}", result); Object value = result.getValue(); if (isValidNumber(value)) { String line = KeyUtils.getKeyString(server, query, result, typeNames, rootPrefix) .replaceAll("[()]", "_") + " " + value.toString() + " " + result.getEpoch() / 1000 + "\n"; log.debug("Graphite Message: {}", line); writer.write(line); } else { onlyOnceLogger.infoOnce("Unable to submit non-numeric value to Graphite: [{}] from result [{}]", value, result); } } } finally { if (writer != null && writer.checkError()) { log.error("Error writing to Graphite, clearing Graphite socket pool"); pool.invalidateObject(address, socket); } else { pool.returnObject(address, socket); } } }
public void destroyConnection(TimeTrackingModuleConnectionKey key, TimeTrackingModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
public void destroyConnection(BenefitsModuleConnectionKey key, BenefitsModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
public void destroyConnection(HumanResourcesModuleConnectionKey key, HumanResourcesModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
public void destroyConnection(PayrollModuleConnectionKey key, PayrollModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
public void invalidateObject(Object key, Object obj) throws Exception { pool.invalidateObject(key, obj); }
public void destroyConnection(CompensationModuleConnectionKey key, CompensationModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
public void destroyConnection(RecruitingModuleConnectionKey key, RecruitingModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
public void destroyConnection(AbsenceModuleConnectionKey key, AbsenceModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
public void destroyConnection(WorkforceModuleConnectionKey key, WorkforceModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
public void destroyConnection(PayrollInterfaceModuleConnectionKey key, PayrollInterfaceModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
public void destroyConnection(PerformanceModuleConnectionKey key, PerformanceModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
public void destroyConnection(TalentModuleConnectionKey key, TalentModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
public void destroyConnection(StaffingModuleConnectionKey key, StaffingModuleConnectionIdentifierAdapter connection) throws Exception { connectionPool.invalidateObject(key, connection); }
private void discardClient(Object client) { if (client != null) { try { transportPool.invalidateObject(getDataEndpointConfiguration().getPublisherKey(), client); } catch (Exception e) { log.error("Error while invalidating the client ", e); } } }
private void discardClient(Object client) { if (client != null) { try { transportPool.invalidateObject(getDataEndpointConfiguration().getPublisherKey(), client); } catch (Exception e) { log.error("Error while invalidating the client ", e); } } }
@Override public void preparePool(final Object key, final boolean populateImmediately) { final long start = System.nanoTime(); final DatabasePoolPreparePoolEvent event = new DatabasePoolPreparePoolEvent(getDatabaseInfo(name)); try { MonitoredGenericKeyedObjectPool.super.invalidateObject(key, populateImmediately); } catch (final Exception e) { throw toException(e); } finally { event.setElapsedTimeNano(System.nanoTime() - start); SystemInstance.get().fireEvent(event); } }