/** * Create a new Authentication module with the specified settings. * * @param restletCloudConfig * The agent configuration. * @param modulesSettings * The modules settings. * @param context * The context. */ public AnalyticsModule(RestletCloudConfig restletCloudConfig, ModulesSettings modulesSettings, Context context) { super(context); analyticsHandler = new AnalyticsHandler(restletCloudConfig, modulesSettings); }
@Override public void run() { flushLogs(); } }, postPeriodInMs, postPeriodInMs);
@Override public synchronized void stop() throws Exception { analyticsHandler.stop(); super.stop(); } }
/** * Adds a task to the executor service to post call logs to the Restlet Cloud * analytics service. * * If the executor service cannot satisfy the request, the call logs are * lost and an error message is logged with the reason of the failure. * * @param logsToPost * The call logs to post to the Restlet Cloud analytics service. */ private void postLogs(CallLogs logsToPost) { try { executorService.execute(new AsyncCallLogsPostTask(logsToPost)); } catch (RejectedExecutionException e) { LOGGER.severe("Posting " + logsToPost.size() + " call logs failed permanently due to \"" + e.getCause().getMessage() + "\"."); errorSendLog(logsToPost); } }
@Override protected void afterHandle(Request request, Response response) { long startTime = (Long) request.getAttributes().get( "org.restlet.startTime"); int duration = (int) (getTimeMillis() - startTime); analyticsHandler.addCallLogToBuffer(request, response, duration, startTime); }
/** * Creates a new Thread that asynchronously posts call logs to Restlet Cloud */ public void flushLogs() { if (callLogs.isEmpty()) { return; } CallLogs logsToPost; synchronized (callLogs) { if (callLogs.isEmpty()) { return; } logsToPost = new CallLogs(callLogs.size()); logsToPost.addAll(callLogs); callLogs.clear(); } postLogs(logsToPost); }
/** * Adds a task to the executor service to post call logs to the Restlet Cloud * analytics service. * * If the executor service cannot satisfy the request, the call logs are * lost and an error message is logged with the reason of the failure. * * @param logsToPost * The call logs to post to the Restlet Cloud analytics service. */ private void postLogs(CallLogs logsToPost) { try { executorService.execute(new AsyncCallLogsPostTask(logsToPost)); } catch (RejectedExecutionException e) { LOGGER.severe("Posting " + logsToPost.size() + " call logs failed permanently due to \"" + e.getCause().getMessage() + "\"."); errorSendLog(logsToPost); } }
@Override protected void afterHandle(Request request, Response response) { long startTime = (Long) request.getAttributes().get( "org.restlet.startTime"); int duration = (int) (getTimeMillis() - startTime); analyticsHandler.addCallLogToBuffer(request, response, duration, startTime); }
/** * Creates a new Thread that asynchronously posts call logs to Restlet Cloud */ public void flushLogs() { if (callLogs.isEmpty()) { return; } CallLogs logsToPost; synchronized (callLogs) { if (callLogs.isEmpty()) { return; } logsToPost = new CallLogs(callLogs.size()); logsToPost.addAll(callLogs); callLogs.clear(); } postLogs(logsToPost); }
@Override public void run() { flushLogs(); } }, postPeriodInMs, postPeriodInMs);
/** * Adds a task to the executor service to post call logs to the Restlet Cloud * analytics service. * * If the executor service cannot satisfy the request, the call logs are * lost and an error message is logged with the reason of the failure. * * @param logsToPost * The call logs to post to the Restlet Cloud analytics service. */ private void postLogs(CallLogs logsToPost) { try { executorService.execute(new AsyncCallLogsPostTask(logsToPost)); } catch (RejectedExecutionException e) { LOGGER.severe("Posting " + logsToPost.size() + " call logs failed permanently due to \"" + e.getCause().getMessage() + "\"."); errorSendLog(logsToPost); } }
@Override public synchronized void stop() throws Exception { analyticsHandler.stop(); super.stop(); } }
@Override protected void afterHandle(Request request, Response response) { long startTime = (Long) request.getAttributes().get( "org.restlet.startTime"); int duration = (int) (getTimeMillis() - startTime); analyticsHandler.addCallLogToBuffer(request, response, duration, startTime); }
/** * Create a new Authentication module with the specified settings. * * @param restletCloudConfig * The agent configuration. * @param modulesSettings * The modules settings. * @param context * The context. */ public AnalyticsModule(RestletCloudConfig restletCloudConfig, ModulesSettings modulesSettings, Context context) { super(context); analyticsHandler = new AnalyticsHandler(restletCloudConfig, modulesSettings); }
/** * Creates a new Thread that asynchronously posts call logs to Restlet Cloud */ public void flushLogs() { if (callLogs.isEmpty()) { return; } CallLogs logsToPost; synchronized (callLogs) { if (callLogs.isEmpty()) { return; } logsToPost = new CallLogs(callLogs.size()); logsToPost.addAll(callLogs); callLogs.clear(); } postLogs(logsToPost); }
@Override public void run() { flushLogs(); } }, postPeriodInMs, postPeriodInMs);
/** * Adds a task to the executor service to post call logs to the Restlet Cloud * analytics service. * * If the executor service cannot satisfy the request, the call logs are * lost and an error message is logged with the reason of the failure. * * @param logsToPost * The call logs to post to the Restlet Cloud analytics service. */ private void postLogs(CallLogs logsToPost) { try { executorService.execute(new AsyncCallLogsPostTask(logsToPost)); } catch (RejectedExecutionException e) { LOGGER.severe("Posting " + logsToPost.size() + " call logs failed permanently due to \"" + e.getCause().getMessage() + "\"."); errorSendLog(logsToPost); } }
@Override public synchronized void stop() throws Exception { analyticsHandler.stop(); super.stop(); } }
@Override protected void afterHandle(Request request, Response response) { long startTime = (Long) request.getAttributes().get( "org.restlet.startTime"); int duration = (int) (getTimeMillis() - startTime); analyticsHandler.addCallLogToBuffer(request, response, duration, startTime); }
/** * Create a new Authentication module with the specified settings. * * @param restletCloudConfig * The agent configuration. * @param modulesSettings * The modules settings. * @param context * The context. */ public AnalyticsModule(RestletCloudConfig restletCloudConfig, ModulesSettings modulesSettings, Context context) { super(context); analyticsHandler = new AnalyticsHandler(restletCloudConfig, modulesSettings); }