Repository: usergrid Updated Branches: refs/heads/master d6f597ae0 -> 63091f349
http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java ---------------------------------------------------------------------- diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java index 9cb8e1d..35dcd5c 100644 --- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java +++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java @@ -34,9 +34,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import rx.Observable; import rx.Subscriber; -import rx.functions.Action1; import rx.functions.Func1; -import rx.schedulers.Schedulers; import java.util.*; import java.util.concurrent.*; @@ -45,7 +43,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class ApplicationQueueManagerImpl implements ApplicationQueueManager { - private static final Logger LOG = LoggerFactory.getLogger(ApplicationQueueManagerImpl.class); + private static final Logger logger = LoggerFactory.getLogger(ApplicationQueueManagerImpl.class); //this is for tests, will not mark initial post complete, set to false for tests @@ -85,14 +83,14 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { long startTime = System.currentTimeMillis(); if (notification.getCanceled() == Boolean.TRUE) { - LOG.info("notification " + notification.getUuid() + " canceled"); + logger.info("notification " + notification.getUuid() + " canceled"); if (jobExecution != null) { jobExecution.killed(); } return; } - LOG.info("notification {} start queuing", notification.getUuid()); + logger.info("notification {} start queuing", notification.getUuid()); final PathQuery<Device> pathQuery = notification.getPathTokens().getPathQuery() ; //devices query final AtomicInteger deviceCount = new AtomicInteger(); //count devices so you can make a judgement on batching @@ -102,7 +100,7 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { //get devices in querystring, and make sure you have access if (pathQuery != null) { final HashMap<Object,ProviderAdapter> notifierMap = getAdapterMap(); - LOG.info("notification {} start query", notification.getUuid()); + logger.info("notification {} start query", notification.getUuid()); final Iterator<Device> iterator = pathQuery.iterator(em); //if there are more pages (defined by PAGE_SIZE) you probably want this to be async, also if this is already a job then don't reschedule if (iterator instanceof ResultsIterator && ((ResultsIterator) iterator).hasPages() && jobExecution == null) { @@ -121,13 +119,13 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { long now = System.currentTimeMillis(); List<EntityRef> devicesRef = getDevices(entity); // resolve group - LOG.info("notification {} queue {} devices, duration "+(System.currentTimeMillis()-now)+" ms", notification.getUuid(), devicesRef.size()); + logger.info("notification {} queue {} devices, duration "+(System.currentTimeMillis()-now)+" ms", notification.getUuid(), devicesRef.size()); for (EntityRef deviceRef : devicesRef) { - LOG.info("notification {} starting to queue device {} ", notification.getUuid(), deviceRef.getUuid()); + logger.info("notification {} starting to queue device {} ", notification.getUuid(), deviceRef.getUuid()); long hash = MurmurHash.hash(deviceRef.getUuid()); if (sketch.estimateCount(hash) > 0) { //look for duplicates - LOG.warn("Maybe Found duplicate device: {}", deviceRef.getUuid()); + logger.warn("Maybe Found duplicate device: {}", deviceRef.getUuid()); continue; } else { sketch.add(hash, 1); @@ -145,11 +143,11 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { notifierKey = entry.getKey().toLowerCase(); break; } - LOG.info("Provider query for notification {} device {} took "+(System.currentTimeMillis()-now)+" ms",notification.getUuid(),deviceRef.getUuid()); + logger.info("Provider query for notification {} device {} took "+(System.currentTimeMillis()-now)+" ms",notification.getUuid(),deviceRef.getUuid()); } if (notifierId == null) { - LOG.info("Notifier did not match for device {} ", deviceRef); + logger.info("Notifier did not match for device {} ", deviceRef); continue; } @@ -158,16 +156,16 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { // update queued time now = System.currentTimeMillis(); notification.setQueued(System.currentTimeMillis()); - LOG.info("notification {} device {} queue time set. duration "+(System.currentTimeMillis()-now)+" ms", notification.getUuid(), deviceRef.getUuid()); + logger.info("notification {} device {} queue time set. duration "+(System.currentTimeMillis()-now)+" ms", notification.getUuid(), deviceRef.getUuid()); } now = System.currentTimeMillis(); qm.sendMessage(message); - LOG.info("notification {} post-queue to device {} duration " + (System.currentTimeMillis() - now) + " ms "+queueName+" queue", notification.getUuid(), deviceRef.getUuid()); + logger.info("notification {} post-queue to device {} duration " + (System.currentTimeMillis() - now) + " ms "+queueName+" queue", notification.getUuid(), deviceRef.getUuid()); deviceCount.incrementAndGet(); queueMeter.mark(); } } catch (Exception deviceLoopException) { - LOG.error("Failed to add devices", deviceLoopException); + logger.error("Failed to add devices", deviceLoopException); errorMessages.add("Failed to add devices for entity: " + entity.getUuid() + " error:" + deviceLoopException); } return entity; @@ -181,13 +179,13 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { .flatMap(entity -> Observable.just(entity).map(entityListFunct) .doOnError(throwable -> { - LOG.error("Failed while writing", + logger.error("Failed while writing", throwable); }) , 10); o.toBlocking().lastOrDefault( null ); - LOG.info( "notification {} done queueing duration {} ms", notification.getUuid(), System.currentTimeMillis() - now); + logger.info( "notification {} done queueing duration {} ms", notification.getUuid(), System.currentTimeMillis() - now); } // update queued time @@ -205,7 +203,7 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { long now = System.currentTimeMillis(); - LOG.info("notification {} updated notification duration {} ms", notification.getUuid(), System.currentTimeMillis() - now); + logger.info("notification {} updated notification duration {} ms", notification.getUuid(), System.currentTimeMillis() - now); //do i have devices, and have i already started batching. if (deviceCount.get() <= 0 || !notification.getDebug()) { @@ -217,7 +215,7 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { } long elapsed = notification.getQueued() != null ? notification.getQueued() - startTime : 0; - LOG.info("notification {} done queuing to {} devices in " + elapsed + " ms", notification.getUuid().toString(), deviceCount.get()); + logger.info("notification {} done queuing to {} devices in " + elapsed + " ms", notification.getUuid().toString(), deviceCount.get()); } /** @@ -246,11 +244,11 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { notifierHashMap.put(uuid, providerAdapter); notifierHashMap.put(uuid.toString(), providerAdapter); if(count++ >= 100){ - LOG.error("ApplicationQueueManager: too many notifiers...breaking out ", notifierHashMap.size()); + logger.error("ApplicationQueueManager: too many notifiers...breaking out ", notifierHashMap.size()); break; } } - LOG.info("ApplicationQueueManager: fetching notifiers finished size={}, duration {} ms", notifierHashMap.size(),System.currentTimeMillis() - now); + logger.info("ApplicationQueueManager: fetching notifiers finished size={}, duration {} ms", notifierHashMap.size(),System.currentTimeMillis() - now); } return notifierHashMap; } @@ -262,7 +260,7 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { */ @Override public Observable sendBatchToProviders(final List<QueueMessage> messages, final String queuePath) { - LOG.info("sending batch of {} notifications.", messages.size()); + logger.info("sending batch of {} notifications.", messages.size()); final Map<Object, ProviderAdapter> notifierMap = getAdapterMap(); final ApplicationQueueManagerImpl proxy = this; @@ -276,7 +274,7 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { ApplicationQueueMessage message = null; try { message = (ApplicationQueueMessage) queueMessage.getBody(); - LOG.info("start sending notification for device {} for Notification: {} on thread "+Thread.currentThread().getId(), message.getDeviceId(), message.getNotificationId()); + logger.info("start sending notification for device {} for Notification: {} on thread "+Thread.currentThread().getId(), message.getDeviceId(), message.getNotificationId()); UUID deviceUUID = message.getDeviceId(); @@ -294,7 +292,7 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { final Map<String, Object> payloads = notification.getPayloads(); final Map<String, Object> translatedPayloads = translatePayloads(payloads, notifierMap); - LOG.info("sending notification for device {} for Notification: {}", deviceUUID, notification.getUuid()); + logger.info("sending notification for device {} for Notification: {}", deviceUUID, notification.getUuid()); try { String notifierName = message.getNotifierKey().toLowerCase(); @@ -306,8 +304,8 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { tracker.failed(0, "Notification is duplicate/expired/cancelled."); }else { if (payload == null) { - if (LOG.isDebugEnabled()) { - LOG.debug("selected device {} for notification {} doesn't have a valid payload. skipping.", deviceUUID, notification.getUuid()); + if (logger.isDebugEnabled()) { + logger.debug("selected device {} for notification {} doesn't have a valid payload. skipping.", deviceUUID, notification.getUuid()); } tracker.failed(0, "failed to match payload to " + message.getNotifierId() + " notifier"); } else { @@ -317,7 +315,7 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { } catch (Exception e) { tracker.failed(0, e.getMessage()); } finally { - LOG.info("sending to device {} for Notification: {} duration " + (System.currentTimeMillis() - now) + " ms", deviceUUID, notification.getUuid()); + logger.info("sending to device {} for Notification: {} duration " + (System.currentTimeMillis() - now) + " ms", deviceUUID, notification.getUuid()); } } } @@ -327,13 +325,13 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { } } catch (Exception e) { - LOG.error("Failure while sending",e); + logger.error("Failure while sending",e); try { if(!messageCommitted && queuePath != null) { qm.commitMessage(queueMessage); } }catch (Exception queueException){ - LOG.error("Failed to commit message.",queueException); + logger.error("Failed to commit message.",queueException); } } return message; @@ -351,7 +349,7 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { providerAdapter.doneSendingNotifications(); } catch ( Exception e ) { - LOG.error( "providerAdapter.doneSendingNotifications: ", e ); + logger.error( "providerAdapter.doneSendingNotifications: ", e ); } } //TODO: check if a notification is done and mark it @@ -364,12 +362,12 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { taskManager.finishedBatch(); } catch ( Exception e ) { - LOG.error( "Failed to finish batch", e ); + logger.error( "Failed to finish batch", e ); } } } return notifications; - } ).doOnError( throwable -> LOG.error( "Failed while sending", throwable ) ); + } ).doOnError( throwable -> logger.error( "Failed while sending", throwable ) ); }, 10 ); return o; @@ -381,7 +379,7 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { try { adapter.stop(); }catch (Exception e){ - LOG.error("failed to stop adapter",e); + logger.error("failed to stop adapter",e); } } } @@ -438,7 +436,7 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { subscriber.onCompleted(); } catch ( Throwable t ) { - LOG.error("failed on subscriber",t); + logger.error("failed on subscriber",t); subscriber.onError( t ); } } @@ -450,17 +448,17 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { for (final ProviderAdapter providerAdapter : providerAdapters) { try { if (providerAdapter != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("checking notifier {} for inactive devices", providerAdapter.getNotifier()); + if (logger.isDebugEnabled()) { + logger.debug("checking notifier {} for inactive devices", providerAdapter.getNotifier()); } providerAdapter.removeInactiveDevices(); - if (LOG.isDebugEnabled()) { - LOG.debug("finished checking notifier {} for inactive devices", providerAdapter.getNotifier()); + if (logger.isDebugEnabled()) { + logger.debug("finished checking notifier {} for inactive devices", providerAdapter.getNotifier()); } } } catch (Exception e) { - LOG.error("checkForInactiveDevices", e); // not + logger.error("checkForInactiveDevices", e); // not // essential so // don't fail, // but log @@ -472,17 +470,17 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { private boolean isOkToSend(Notification notification) { Map<String,Long> stats = notification.getStatistics(); if (stats != null && notification.getExpectedCount() == (stats.get("sent")+ stats.get("errors"))) { - LOG.info("notification {} already processed. not sending.", + logger.info("notification {} already processed. not sending.", notification.getUuid()); return false; } if (notification.getCanceled() == Boolean.TRUE) { - LOG.info("notification {} canceled. not sending.", + logger.info("notification {} canceled. not sending.", notification.getUuid()); return false; } if (notification.isExpired()) { - LOG.info("notification {} expired. not sending.", + logger.info("notification {} expired. not sending.", notification.getUuid()); return false; } @@ -515,7 +513,7 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager { } return value != null ? value.toString() : null; } catch (Exception e) { - LOG.error("Errer getting provider ID, proceding with rest of batch", e); + logger.error("Errer getting provider ID, proceding with rest of batch", e); return null; } } http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java ---------------------------------------------------------------------- diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java index f2946df..b256dec 100644 --- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java +++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java @@ -36,7 +36,6 @@ import org.apache.usergrid.services.notifications.TaskTracker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.*; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -46,7 +45,7 @@ import java.util.Map; */ public class WNSAdapter implements ProviderAdapter { - private static final Logger LOG = LoggerFactory.getLogger(WNSAdapter.class); + private static final Logger logger = LoggerFactory.getLogger(WNSAdapter.class); private final EntityManager entityManager; private final Notifier notifier; @@ -65,7 +64,7 @@ public class WNSAdapter implements ProviderAdapter { //this fails every time due to jax error which is ok service.pushToast("s-1-15-2-2411381248-444863693-3819932088-4077691928-1194867744-112853457-373132695", toast); }catch (ClientHandlerException e){ - LOG.info("Windows Phone notifier added: " + e.toString()); + logger.info("Windows Phone notifier added: " + e.toString()); } } @@ -118,7 +117,7 @@ public class WNSAdapter implements ProviderAdapter { tracker.completed(); } catch (Exception e) { tracker.failed(0,e.toString()); - LOG.error("Failed to send notification",e); + logger.error("Failed to send notification",e); } } http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/services/src/main/java/org/apache/usergrid/services/queues/QueueListener.java ---------------------------------------------------------------------- diff --git a/stack/services/src/main/java/org/apache/usergrid/services/queues/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/queues/QueueListener.java index 5404e6b..b1c90d1 100644 --- a/stack/services/src/main/java/org/apache/usergrid/services/queues/QueueListener.java +++ b/stack/services/src/main/java/org/apache/usergrid/services/queues/QueueListener.java @@ -30,7 +30,6 @@ import org.apache.usergrid.services.ServiceManager; import org.apache.usergrid.services.ServiceManagerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import rx.*; import javax.annotation.PostConstruct; import java.util.*; @@ -48,7 +47,7 @@ public abstract class QueueListener { public long DEFAULT_SLEEP = 5000; - private static final Logger LOG = LoggerFactory.getLogger(QueueListener.class); + private static final Logger logger = LoggerFactory.getLogger(QueueListener.class); private MetricsFactory metricsService; @@ -104,7 +103,7 @@ public abstract class QueueListener { boolean shouldRun = new Boolean(properties.getProperty("usergrid.queues.listener.run", "true")); if(shouldRun) { - LOG.info("QueueListener: starting."); + logger.info("QueueListener: starting."); int threadCount = 0; try { @@ -123,25 +122,25 @@ public abstract class QueueListener { pool = Executors.newFixedThreadPool(maxThreads); while (threadCount++ < maxThreads) { - LOG.info("QueueListener: Starting thread {}.", threadCount); + logger.info("QueueListener: Starting thread {}.", threadCount); Runnable task = new Runnable() { @Override public void run() { try { execute(); } catch (Exception e) { - LOG.error("failed to start push", e); + logger.error("failed to start push", e); } } }; futures.add( pool.submit(task)); } } catch (Exception e) { - LOG.error("QueueListener: failed to start:", e); + logger.error("QueueListener: failed to start:", e); } - LOG.info("QueueListener: done starting."); + logger.info("QueueListener: done starting."); }else{ - LOG.info("QueueListener: never started due to config value usergrid.queues.listener.run."); + logger.info("QueueListener: never started due to config value usergrid.queues.listener.run."); } } @@ -158,9 +157,9 @@ public abstract class QueueListener { Thread.currentThread().setName("queues_Processor"+UUID.randomUUID()); final AtomicInteger consecutiveExceptions = new AtomicInteger(); - LOG.info("QueueListener: Starting execute process."); + logger.info("QueueListener: Starting execute process."); svcMgr = smf.getServiceManager(smf.getManagementAppId()); - LOG.info("getting from queue {} ", queueName); + logger.info("getting from queue {} ", queueName); QueueScope queueScope = new QueueScopeImpl( queueName, QueueScope.RegionImplementation.LOCAL); QueueManager queueManager = TEST_QUEUE_MANAGER != null ? TEST_QUEUE_MANAGER : queueManagerFactory.getQueueManager(queueScope); // run until there are no more active jobs @@ -177,7 +176,7 @@ public abstract class QueueListener { .buffer(getBatchSize()) .doOnNext(messages -> { try { - LOG.info("retrieved batch of {} messages from queue {} ", messages.size(), queueName); + logger.info("retrieved batch of {} messages from queue {} ", messages.size(), queueName); if (messages.size() > 0) { @@ -190,30 +189,30 @@ public abstract class QueueListener { queueManager.commitMessages(messages); meter.mark(messages.size()); - LOG.info("sent batch {} messages duration {} ms", messages.size(), System.currentTimeMillis() - now); + logger.info("sent batch {} messages duration {} ms", messages.size(), System.currentTimeMillis() - now); if (sleepBetweenRuns > 0) { - LOG.info("sleep between rounds...sleep...{}", sleepBetweenRuns); + logger.info("sleep between rounds...sleep...{}", sleepBetweenRuns); Thread.sleep(sleepBetweenRuns); } } else { - LOG.info("no messages...sleep...{}", sleepWhenNoneFound); + logger.info("no messages...sleep...{}", sleepWhenNoneFound); Thread.sleep(sleepWhenNoneFound); } timerContext.stop(); //send to the providers consecutiveExceptions.set(0); } catch (Exception ex) { - LOG.error("failed to dequeue", ex); + logger.error("failed to dequeue", ex); try { long sleeptime = sleepWhenNoneFound * consecutiveExceptions.incrementAndGet(); long maxSleep = 15000; sleeptime = sleeptime > maxSleep ? maxSleep : sleeptime; - LOG.info("sleeping due to failures {} ms", sleeptime); + logger.info("sleeping due to failures {} ms", sleeptime); Thread.sleep(sleeptime); } catch (InterruptedException ie) { - LOG.info("sleep interrupted"); + logger.info("sleep interrupted"); } } }).toBlocking().lastOrDefault(null); @@ -222,7 +221,7 @@ public abstract class QueueListener { public void stop(){ - LOG.info("stop processes"); + logger.info("stop processes"); if(futures == null){ return; http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/services/src/test/java/org/apache/usergrid/NewOrgAppAdminRule.java ---------------------------------------------------------------------- diff --git a/stack/services/src/test/java/org/apache/usergrid/NewOrgAppAdminRule.java b/stack/services/src/test/java/org/apache/usergrid/NewOrgAppAdminRule.java index 5771b67..659520e 100644 --- a/stack/services/src/test/java/org/apache/usergrid/NewOrgAppAdminRule.java +++ b/stack/services/src/test/java/org/apache/usergrid/NewOrgAppAdminRule.java @@ -41,7 +41,7 @@ import static org.apache.usergrid.TestHelper.newUUIDString; */ public class NewOrgAppAdminRule implements TestRule { - private static final Logger LOG = LoggerFactory.getLogger( CoreApplication.class ); + private static final Logger logger = LoggerFactory.getLogger( CoreApplication.class ); public static final String ADMIN_NAME = "Test Admin"; public static final String ADMIN_PASSWORD = "password"; @@ -76,7 +76,7 @@ public class NewOrgAppAdminRule implements TestRule { protected void after( Description description ) { - LOG.info( "Test {}: finish with application", description.getDisplayName() ); + logger.info( "Test {}: finish with application", description.getDisplayName() ); } http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java ---------------------------------------------------------------------- diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java index 1ed10df..89ff272 100644 --- a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java +++ b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java @@ -22,8 +22,6 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -import org.apache.usergrid.persistence.cache.CacheScope; -import org.apache.usergrid.persistence.cache.ScopedCache; import org.junit.runner.Description; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,7 +44,7 @@ import static org.apache.usergrid.utils.InflectionUtils.pluralize; public class ServiceApplication extends CoreApplication { - private static final Logger LOG = LoggerFactory.getLogger( ServiceApplication.class ); + private static final Logger logger = LoggerFactory.getLogger( ServiceApplication.class ); protected ServiceManager sm; protected ServiceITSetup svcSetup; @@ -100,7 +98,7 @@ public class ServiceApplication extends CoreApplication { public ServiceResults invokeService( ServiceAction action, Object... params ) throws Exception { ServiceRequest request = sm.newRequest( action, parameters( params ), payload( properties ) ); - LOG.info( "Request: {} {}", action, request.toString() ); + logger.info( "Request: {} {}", action, request.toString() ); dumpProperties( properties ); ServiceResults results = request.execute(); assertNotNull( results ); @@ -115,8 +113,8 @@ public class ServiceApplication extends CoreApplication { public void dumpProperties( Map<String, Object> properties ) { - if ( properties != null && LOG.isInfoEnabled() ) { - LOG.info( "Input:\n {}", JsonUtils.mapToFormattedJsonString( properties ) ); + if ( properties != null && logger.isInfoEnabled() ) { + logger.info( "Input:\n {}", JsonUtils.mapToFormattedJsonString( properties ) ); } } @@ -147,7 +145,7 @@ public class ServiceApplication extends CoreApplication { public ServiceResults testBatchRequest( ServiceAction action, int expectedCount, List<Map<String, Object>> batch, Object... params ) throws Exception { ServiceRequest request = sm.newRequest( action, parameters( params ), batchPayload( batch ) ); - LOG.info( "Request: " + action + " " + request.toString() ); + logger.info( "Request: " + action + " " + request.toString() ); // dump( "Batch", batch ); ServiceResults results = request.execute(); assertNotNull( results ); @@ -164,7 +162,7 @@ public class ServiceApplication extends CoreApplication { public ServiceResults testDataRequest( ServiceAction action, Object... params ) throws Exception { ServiceRequest request = sm.newRequest( action, parameters( params ), payload( properties ) ); - LOG.info( "Request: {} {}", action, request.toString() ); + logger.info( "Request: {} {}", action, request.toString() ); dumpProperties( properties ); ServiceResults results = request.execute(); assertNotNull( results ); http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java ---------------------------------------------------------------------- diff --git a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java index 3d14c2f..599a796 100644 --- a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java +++ b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java @@ -57,7 +57,7 @@ import static org.junit.Assert.*; */ @NotThreadSafe public class EmailFlowIT { - private static final Logger LOG = LoggerFactory.getLogger( EmailFlowIT.class ); + private static final Logger logger = LoggerFactory.getLogger( EmailFlowIT.class ); @Rule public org.apache.usergrid.Application app = new CoreApplication( setup ); @@ -101,7 +101,7 @@ public class EmailFlowIT { assertEquals( "User Account Confirmation: " + email, confirmation.getSubject() ); String token = getTokenFromMessage( confirmation ); - LOG.info( token ); + logger.info( token ); assertEquals( ActivationState.ACTIVATED, setup.getMgmtSvc().handleConfirmationTokenForAdminUser( org_owner.owner.getUuid(), token ) ); @@ -141,7 +141,7 @@ public class EmailFlowIT { assertEquals( "User Account Confirmation: "+email, confirmation.getSubject() ); String token = getTokenFromMessage( confirmation ); - LOG.info( token ); + logger.info( token ); ActivationState state = setup.getMgmtSvc().handleConfirmationTokenForAdminUser( org_owner.owner.getUuid(), token ); @@ -162,7 +162,7 @@ public class EmailFlowIT { assertEquals( "Request For Admin User Account Activation "+email, activation.getSubject() ); token = getTokenFromMessage( activation ); - LOG.info( token ); + logger.info( token ); state = setup.getMgmtSvc().handleActivationTokenForAdminUser( org_owner.owner.getUuid(), token ); assertEquals( ActivationState.ACTIVATED, state ); @@ -266,12 +266,12 @@ public class EmailFlowIT { // activation url ok String mailContent = ( String ) ( ( MimeMultipart ) activation.getContent() ).getBodyPart( 1 ).getContent(); - LOG.info( mailContent ); + logger.info( mailContent ); assertTrue( StringUtils.contains( mailContent.toLowerCase(), activation_url.toLowerCase() ) ); // token ok String token = getTokenFromMessage( activation ); - LOG.info( token ); + logger.info( token ); ActivationState activeState = setup.getMgmtSvc().handleActivationTokenForAppUser( app.getId(), appUser.getUuid(), token ); assertEquals( ActivationState.ACTIVATED, activeState ); @@ -294,12 +294,12 @@ public class EmailFlowIT { // resetpwd url ok mailContent = ( String ) ( ( MimeMultipart ) reset.getContent() ).getBodyPart( 1 ).getContent(); - LOG.info( mailContent ); + logger.info( mailContent ); assertTrue( StringUtils.contains( mailContent.toLowerCase(), reset_url.toLowerCase() ) ); // token ok token = getTokenFromMessage( reset ); - LOG.info( token ); + logger.info( token ); assertTrue( setup.getMgmtSvc().checkPasswordResetTokenForAppUser( app.getId(), appUser.getUuid(), token ) ); // ensure revoke works @@ -356,12 +356,12 @@ public class EmailFlowIT { // confirmation url ok String mailContent = ( String ) ( ( MimeMultipart ) confirmation.getContent() ).getBodyPart( 1 ).getContent(); - LOG.info( mailContent ); + logger.info( mailContent ); assertTrue( StringUtils.contains( mailContent.toLowerCase(), confirmation_url.toLowerCase() ) ); // token ok String token = getTokenFromMessage( confirmation ); - LOG.info( token ); + logger.info( token ); ActivationState activeState = setup.getMgmtSvc().handleConfirmationTokenForAppUser( app.getId(), user.getUuid(), token ); assertEquals( ActivationState.CONFIRMED_AWAITING_ACTIVATION, activeState ); @@ -393,7 +393,7 @@ public class EmailFlowIT { private void testProperty( String propertyName, boolean containsSubstitution ) { String propertyValue = setup.get( propertyName ); assertTrue( propertyName + " was not found", isNotBlank( propertyValue ) ); - LOG.info( propertyName + "=" + propertyValue ); + logger.info( propertyName + "=" + propertyValue ); if ( containsSubstitution ) { Map<String, String> valuesMap = new HashMap<String, String>(); http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java ---------------------------------------------------------------------- diff --git a/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java b/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java index 0bd4f41..075ee03 100644 --- a/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java +++ b/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java @@ -31,12 +31,10 @@ import org.apache.shiro.subject.Subject; import org.apache.usergrid.ServiceITSetup; import org.apache.usergrid.ServiceITSetupImpl; -import org.apache.usergrid.cassandra.SpringResource; import org.apache.usergrid.cassandra.ClearShiroSubject; import org.apache.usergrid.persistence.EntityManager; import org.apache.usergrid.persistence.entities.User; -import org.apache.usergrid.persistence.index.impl.ElasticSearchResource; import org.apache.usergrid.security.shiro.PrincipalCredentialsToken; import org.apache.usergrid.security.shiro.utils.SubjectUtils; @@ -45,7 +43,7 @@ import static org.junit.Assert.assertFalse; public class RoleIT { - private static final Logger LOG = LoggerFactory.getLogger( RoleIT.class ); + private static final Logger logger = LoggerFactory.getLogger( RoleIT.class ); @Rule public ClearShiroSubject clearShiroSubject = new ClearShiroSubject(); @@ -89,7 +87,7 @@ public class RoleIT { subject.checkRole( "application-role:" + applicationId + ":logged-in" ); - LOG.info( "Has role \"logged-in\"" ); + logger.info( "Has role \"logged-in\"" ); Thread.sleep( 2100 ); @@ -97,6 +95,6 @@ public class RoleIT { assertFalse( subject.hasRole( "application-role:" + applicationId + ":logged-in" ) ); - LOG.info( "Doesn't have role \"logged-in\"" ); + logger.info( "Doesn't have role \"logged-in\"" ); } } http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java ---------------------------------------------------------------------- diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java index ad2ce66..270a6cb 100644 --- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java +++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java @@ -58,7 +58,7 @@ import static org.junit.Assert.*; */ public class ManagementServiceIT { - private static final Logger LOG = LoggerFactory.getLogger( ManagementServiceIT.class ); + private static final Logger logger = LoggerFactory.getLogger( ManagementServiceIT.class ); @ClassRule @@ -79,7 +79,7 @@ public class ManagementServiceIT { @Before public void setup() throws Exception { - LOG.info( "in setup" ); + logger.info( "in setup" ); adminUser = orgAppAdminRule.getAdminInfo(); @@ -140,8 +140,8 @@ public class ManagementServiceIT { EntityManager em = setup.getEmf().getEntityManager( setup.getEmf().getManagementAppId() ); Map<String, Long> counts = em.getApplicationCounters(); - LOG.info( JsonUtils.mapToJsonString( counts ) ); - LOG.info( JsonUtils.mapToJsonString( em.getCounterNames() ) ); + logger.info( JsonUtils.mapToJsonString( counts ) ); + logger.info( JsonUtils.mapToJsonString( em.getCounterNames() ) ); final Long existingCounts = counts.get( "admin_logins" ); @@ -152,8 +152,8 @@ public class ManagementServiceIT { counts = em.getApplicationCounters(); - LOG.info( JsonUtils.mapToJsonString( counts ) ); - LOG.info( JsonUtils.mapToJsonString( em.getCounterNames() ) ); + logger.info( JsonUtils.mapToJsonString( counts ) ); + logger.info( JsonUtils.mapToJsonString( em.getCounterNames() ) ); assertNotNull( counts.get( "admin_logins" ) ); final long newCount = counts.get( "admin_logins" ); http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java ---------------------------------------------------------------------- diff --git a/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java index b5471ec..c4cc10c 100644 --- a/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java +++ b/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java @@ -52,7 +52,7 @@ import static org.junit.Assert.assertTrue; public class TokenServiceIT { - private static final Logger log = LoggerFactory.getLogger( TokenServiceIT.class ); + private static final Logger logger = LoggerFactory.getLogger( TokenServiceIT.class ); // app-level data generated only once per test private UserInfo adminUser; @@ -68,7 +68,7 @@ public class TokenServiceIT { @Before public void setup() throws Exception { - log.info( "in setup" ); + logger.info( "in setup" ); adminUser = newOrgAppAdminRule.getAdminInfo(); } @@ -87,7 +87,7 @@ public class TokenServiceIT { String tokenStr = setup.getTokenSvc().createToken( TokenCategory.EMAIL, "email_confirm", null, data, 0 ); - log.info( "token: " + tokenStr ); + logger.info( "token: " + tokenStr ); TokenInfo tokenInfo = setup.getTokenSvc().getTokenInfo( tokenStr ); @@ -111,7 +111,7 @@ public class TokenServiceIT { String tokenStr = setup.getTokenSvc().createToken( TokenCategory.ACCESS, null, adminPrincipal, null, 0 ); - log.info( "token: " + tokenStr ); + logger.info( "token: " + tokenStr ); TokenInfo tokenInfo = setup.getTokenSvc().getTokenInfo( tokenStr ); @@ -451,7 +451,7 @@ public class TokenServiceIT { String tokenStr = setup.getTokenSvc().createToken( TokenCategory.ACCESS, null, adminPrincipal, null, 0 ); - log.info("token: " + tokenStr); + logger.info("token: " + tokenStr); // revoke token and check to make sure it is no longer valid http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java ---------------------------------------------------------------------- diff --git a/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java b/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java index ceaf996..57f0bb2 100644 --- a/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java +++ b/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java @@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; public class ServiceInvocationIT extends AbstractServiceIT { - private static final Logger LOG = LoggerFactory.getLogger( ServiceInvocationIT.class ); + private static final Logger logger = LoggerFactory.getLogger( ServiceInvocationIT.class ); @Rule public ClearShiroSubject clearShiroSubject = new ClearShiroSubject(); @@ -44,7 +44,7 @@ public class ServiceInvocationIT extends AbstractServiceIT { @Test public void testServices() throws Exception { - LOG.info( "testServices" ); + logger.info( "testServices" ); app.put( "username", "edanuff" ); app.put( "email", "[email protected]" ); http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/test-utils/src/main/java/org/apache/usergrid/TomcatMain.java ---------------------------------------------------------------------- diff --git a/stack/test-utils/src/main/java/org/apache/usergrid/TomcatMain.java b/stack/test-utils/src/main/java/org/apache/usergrid/TomcatMain.java index d575bc7..c964b32 100644 --- a/stack/test-utils/src/main/java/org/apache/usergrid/TomcatMain.java +++ b/stack/test-utils/src/main/java/org/apache/usergrid/TomcatMain.java @@ -26,8 +26,8 @@ import org.slf4j.LoggerFactory; * Simple wrapper for starting "embedded" Tomcat as it's own process, for testing. */ public class TomcatMain { - - private static final Logger log = LoggerFactory.getLogger( TomcatMain.class ); + + private static final Logger logger = LoggerFactory.getLogger( TomcatMain.class ); public static void main(String[] args) throws Exception { @@ -43,9 +43,9 @@ public class TomcatMain { tomcat.getConnector().setAttribute("maxThreads", "1000"); tomcat.addWebapp("/", new File(webappsPath).getAbsolutePath()); - log.info("-----------------------------------------------------------------"); - log.info("Starting Tomcat port {} dir {}", port, webappsPath); - log.info("-----------------------------------------------------------------"); + logger.info("-----------------------------------------------------------------"); + logger.info("Starting Tomcat port {} dir {}", port, webappsPath); + logger.info("-----------------------------------------------------------------"); tomcat.start(); while ( true ) { http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/AvailablePortFinder.java ---------------------------------------------------------------------- diff --git a/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/AvailablePortFinder.java b/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/AvailablePortFinder.java index c392146..1d7ee21 100644 --- a/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/AvailablePortFinder.java +++ b/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/AvailablePortFinder.java @@ -37,8 +37,8 @@ import org.slf4j.LoggerFactory; * @see <a href="http://www.iana.org/assignments/port-numbers">IANA.org</a> */ public class AvailablePortFinder { - - private static final Logger LOG = LoggerFactory.getLogger( AvailablePortFinder.class ); + + private static final Logger logger = LoggerFactory.getLogger( AvailablePortFinder.class ); /** The minimum number of server port number. */ public static final int MIN_PORT_NUMBER = 1; @@ -126,24 +126,24 @@ public class AvailablePortFinder { // Jackson: It seems like the code below intends to // setReuseAddress(true), but that needs to be set before the bind. // The constructor for the ServerSocket(int) will bind, so not sure - // how it would have been working as intended previously. - + // how it would have been working as intended previously. + // Changing ServerSocket constructor to use default constructor, // this would be unbound, then set the socket reuse, and // call the bind separately - + //ss = new ServerSocket( port ); ss = new ServerSocket(); ss.setReuseAddress( true ); ss.bind(new InetSocketAddress((InetAddress) null, port), 0); - + // Unlike ServerSocket, the default constructor of DatagramSocket - // will bound. To create an unbound DatagramSocket, use null address + // will bound. To create an unbound DatagramSocket, use null address //ds = new DatagramSocket( port ); ds = new DatagramSocket(null); ds.setReuseAddress( true ); ds.bind(new InetSocketAddress((InetAddress) null, port)); - LOG.info("port {} available", port); + logger.info("port {} available", port); return true; } catch ( IOException e ) { @@ -163,7 +163,7 @@ public class AvailablePortFinder { } } } - LOG.info("port {} unavailable", port); + logger.info("port {} unavailable", port); return false; } http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/CassandraResource.java ---------------------------------------------------------------------- diff --git a/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/CassandraResource.java b/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/CassandraResource.java index 99ae2c5..a87af41 100644 --- a/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/CassandraResource.java +++ b/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/CassandraResource.java @@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory; public class CassandraResource extends EnvironResource { - public static final Logger LOG = LoggerFactory.getLogger( SpringResource.class ); + public static final Logger logger = LoggerFactory.getLogger( SpringResource.class ); public static final String DEFAULT_HOST = "127.0.0.1"; @@ -88,7 +88,7 @@ public class CassandraResource extends EnvironResource { props.load( ClassLoader.getSystemResourceAsStream( "project.properties" ) ); } catch ( IOException e ) { - LOG.error( "Unable to load project properties: {}", e.getLocalizedMessage() ); + logger.error( "Unable to load project properties: {}", e.getLocalizedMessage() ); } port = Integer.parseInt( props.getProperty( "cassandra.rpcPort", Integer.toString( DEFAULT_RPC_PORT ) ) ); @@ -108,7 +108,7 @@ public class CassandraResource extends EnvironResource { System.setProperty( "cassandra." + RPC_PORT_KEY, Integer.toString( port ) ); - LOG.info( "project.properties loaded properties for ports : " + "[rpc] = [{}]", new Object[] { port } ); + logger.info( "project.properties loaded properties for ports : " + "[rpc] = [{}]", new Object[] { port } ); initialized = true; http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/ClearShiroSubject.java ---------------------------------------------------------------------- diff --git a/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/ClearShiroSubject.java b/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/ClearShiroSubject.java index 4010b04..e46cc0c 100644 --- a/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/ClearShiroSubject.java +++ b/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/ClearShiroSubject.java @@ -22,15 +22,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.shiro.SecurityUtils; -import org.apache.shiro.mgt.*; -import org.apache.shiro.mgt.SecurityManager; import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.support.SubjectThreadState; /** A {@link org.junit.rules.TestRule} that cleans up the Shiro Subject's ThreadState. */ public class ClearShiroSubject extends ExternalResource { - private static final Logger LOG = LoggerFactory.getLogger( ClearShiroSubject.class ); + private static final Logger logger = LoggerFactory.getLogger( ClearShiroSubject.class ); @@ -51,12 +49,12 @@ public class ClearShiroSubject extends ExternalResource { if ( subject == null ) { - LOG.info( "Shiro Subject was null. No need to clear manually." ); + logger.info( "Shiro Subject was null. No need to clear manually." ); return; } new SubjectThreadState( subject ).clear(); - LOG.info( "Shiro Subject was NOT null. Subject has been cleared manually." ); + logger.info( "Shiro Subject was NOT null. Subject has been cleared manually." ); } } http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/SpringResource.java ---------------------------------------------------------------------- diff --git a/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/SpringResource.java b/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/SpringResource.java index 7d3782d..01e9e6b 100644 --- a/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/SpringResource.java +++ b/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/SpringResource.java @@ -31,7 +31,7 @@ import org.apache.usergrid.persistence.index.impl.ElasticSearchResource; * spring context within this singleton */ public class SpringResource { - public static final Logger LOG = LoggerFactory.getLogger( SpringResource.class ); + public static final Logger logger = LoggerFactory.getLogger( SpringResource.class ); private static SpringResource instance; @@ -44,12 +44,12 @@ public class SpringResource { * Cassandra. */ private SpringResource() { - LOG.info( "Creating CassandraResource using {} for the ClassLoader.", + logger.info( "Creating CassandraResource using {} for the ClassLoader.", Thread.currentThread().getContextClassLoader() ); - LOG.info( "-------------------------------------------------------------------" ); - LOG.info( "Initializing Spring" ); - LOG.info( "-------------------------------------------------------------------" ); + logger.info( "-------------------------------------------------------------------" ); + logger.info( "Initializing Spring" ); + logger.info( "-------------------------------------------------------------------" ); //wire up cassandra and elasticsearch before we start spring, otherwise this won't work http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/test-utils/src/test/java/org/apache/usergrid/cassandra/SpringResourceTest.java ---------------------------------------------------------------------- diff --git a/stack/test-utils/src/test/java/org/apache/usergrid/cassandra/SpringResourceTest.java b/stack/test-utils/src/test/java/org/apache/usergrid/cassandra/SpringResourceTest.java index 140e318..52d1483 100644 --- a/stack/test-utils/src/test/java/org/apache/usergrid/cassandra/SpringResourceTest.java +++ b/stack/test-utils/src/test/java/org/apache/usergrid/cassandra/SpringResourceTest.java @@ -27,7 +27,7 @@ import static junit.framework.TestCase.assertSame; /** This tests the CassandraResource. */ public class SpringResourceTest { - public static final Logger LOG = LoggerFactory.getLogger( SpringResourceTest.class ); + public static final Logger logger = LoggerFactory.getLogger( SpringResourceTest.class ); @@ -40,18 +40,18 @@ public class SpringResourceTest { @Test public void testDoubleTrouble() throws Throwable { SpringResource c1 = SpringResource.getInstance(); - LOG.info( "Starting up first Spring instance: {}", c1 ); + logger.info( "Starting up first Spring instance: {}", c1 ); - LOG.debug( "Waiting for the new instance to come online." ); + logger.debug( "Waiting for the new instance to come online." ); SchemaManager c1SchemaManager = c1.getBean( SchemaManager.class ); SpringResource c2 = SpringResource.getInstance(); - LOG.debug( "Starting up second Spring instance: {}", c2 ); + logger.debug( "Starting up second Spring instance: {}", c2 ); SchemaManager c2SchemaManager = c2.getBean( SchemaManager.class ); - LOG.debug( "Waiting a few seconds for second instance to be ready before shutting down." ); + logger.debug( "Waiting a few seconds for second instance to be ready before shutting down." ); assertSame("Instances should be from the same spring context", c1SchemaManager, c2SchemaManager); http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/tools/src/main/java/org/apache/usergrid/tools/WarehouseExport.java ---------------------------------------------------------------------- diff --git a/stack/tools/src/main/java/org/apache/usergrid/tools/WarehouseExport.java b/stack/tools/src/main/java/org/apache/usergrid/tools/WarehouseExport.java index 564bd7e..48d47be 100644 --- a/stack/tools/src/main/java/org/apache/usergrid/tools/WarehouseExport.java +++ b/stack/tools/src/main/java/org/apache/usergrid/tools/WarehouseExport.java @@ -63,7 +63,7 @@ import static org.apache.usergrid.persistence.Schema.getDefaultSchema; */ public class WarehouseExport extends ExportingToolBase { - private static final Logger LOG = LoggerFactory.getLogger( WarehouseExport.class ); + private static final Logger logger = LoggerFactory.getLogger( WarehouseExport.class ); private static final char SEPARATOR = '|'; public static final String BUCKET_PROPNAME = "usergrid.warehouse-export-bucket"; @@ -115,14 +115,14 @@ public class WarehouseExport extends ExportingToolBase { applyOrgId( line ); prepareBaseOutputFileName( line ); outputDir = createOutputParentDir(); - LOG.info( "Export directory: {}", outputDir.getAbsolutePath() ); + logger.info( "Export directory: {}", outputDir.getAbsolutePath() ); // create writer applyStartTime( line ); applyEndTime( line ); - LOG.error( "startTime: {}, endTime: {}", startTime, endTime ); + logger.error( "startTime: {}, endTime: {}", startTime, endTime ); if ( startTime.getTime() >= endTime.getTime() ) { - LOG.error( "startTime must be before endTime. exiting." ); + logger.error( "startTime must be before endTime. exiting." ); System.exit( 1 ); } @@ -154,7 +154,7 @@ public class WarehouseExport extends ExportingToolBase { // now that file is written, copy it to S3 if ( line.hasOption( "upload" ) ) { - LOG.info( "Copy to S3" ); + logger.info( "Copy to S3" ); copyToS3( fileName ); } } @@ -183,7 +183,7 @@ public class WarehouseExport extends ExportingToolBase { s3Client.createBucket( bucketName ); File uploadFile = new File( fileName ); PutObjectResult putObjectResult = s3Client.putObject( bucketName, uploadFile.getName(), uploadFile ); - LOG.info("Uploaded file etag={}", putObjectResult.getETag()); + logger.info("Uploaded file etag={}", putObjectResult.getETag()); } @@ -341,7 +341,7 @@ public class WarehouseExport extends ExportingToolBase { OrganizationInfo info = managementService.getOrganizationByUuid( orgId ); if ( info == null ) { - LOG.error( "Organization info is null!" ); + logger.error( "Organization info is null!" ); System.exit( 1 ); } @@ -377,7 +377,7 @@ public class WarehouseExport extends ExportingToolBase { private void exportApplicationsForOrg( Entry<UUID, String> orgIdAndName, String queryString ) throws Exception { - LOG.info( "organization: {} / {}", orgIdAndName.getValue(), orgIdAndName.getKey() ); + logger.info( "organization: {} / {}", orgIdAndName.getValue(), orgIdAndName.getKey() ); String orgName = orgIdAndName.getValue(); @@ -387,7 +387,7 @@ public class WarehouseExport extends ExportingToolBase { String appName = appIdAndName.getValue(); appName = appName.substring( appName.indexOf( '/' ) + 1 ); - LOG.info( "application {} / {}", appName, appIdAndName.getKey() ); + logger.info( "application {} / {}", appName, appIdAndName.getKey() ); EntityManager em = emf.getEntityManager( appIdAndName.getKey() ); Map<String, String[]> cfm = getCollectionFieldMap(); http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/tools/src/main/java/org/apache/usergrid/tools/WarehouseUpsert.java ---------------------------------------------------------------------- diff --git a/stack/tools/src/main/java/org/apache/usergrid/tools/WarehouseUpsert.java b/stack/tools/src/main/java/org/apache/usergrid/tools/WarehouseUpsert.java index 158abd6..901fb7e 100644 --- a/stack/tools/src/main/java/org/apache/usergrid/tools/WarehouseUpsert.java +++ b/stack/tools/src/main/java/org/apache/usergrid/tools/WarehouseUpsert.java @@ -31,7 +31,7 @@ import org.apache.commons.io.IOUtils; /** Upserts data from files found in an S3 bucket. */ public class WarehouseUpsert extends ExportingToolBase { - private static final Logger LOG = LoggerFactory.getLogger( WarehouseUpsert.class ); + private static final Logger logger = LoggerFactory.getLogger( WarehouseUpsert.class ); public static final String DBHOST_PROPNAME = "usergrid.warehouse-export-dbhost"; public static final String DBPORT_PROPNAME = "usergrid.warehouse-export-dbport"; @@ -84,14 +84,14 @@ public class WarehouseUpsert extends ExportingToolBase { String mainTableName = ( String ) properties.get( MAIN_TABLE_PROPNAME ); try { con.createStatement().execute( createWarehouseTable( mainTableName ) ); - LOG.info( "Created main table " + mainTableName ); + logger.info( "Created main table " + mainTableName ); } catch ( SQLException ex ) { if ( !ex.getMessage().contains( "already exists" ) ) { - LOG.error( "Error creating main table: " + ex.getMessage(), ex ); + logger.error( "Error creating main table: " + ex.getMessage(), ex ); } else { - LOG.info( "Using existing main table " + mainTableName ); + logger.info( "Using existing main table " + mainTableName ); } } @@ -100,47 +100,47 @@ public class WarehouseUpsert extends ExportingToolBase { String dropStagingTable = String.format( "drop table %s", stagingTableName ); try { con.createStatement().execute( dropStagingTable ); - LOG.info( "Dropped existing staging table " + stagingTableName ); + logger.info( "Dropped existing staging table " + stagingTableName ); } catch ( SQLException ex ) { if ( !ex.getMessage().contains( "does not exist" ) ) { - LOG.error( "Error dropping staging table: " + ex.getMessage(), ex ); + logger.error( "Error dropping staging table: " + ex.getMessage(), ex ); } else { - LOG.info( "Using existing staging table " + stagingTableName ); + logger.info( "Using existing staging table " + stagingTableName ); } } // create staging table - LOG.info( "Creating new staging table" ); + logger.info( "Creating new staging table" ); con.createStatement().execute( createWarehouseTable( stagingTableName ) ); // copy data from S3 into staging table - LOG.info( "Copying data from S3" ); + logger.info( "Copying data from S3" ); String copyFromS3 = String.format( "COPY %s FROM 's3://%s' " + "CREDENTIALS 'aws_access_key_id=%s;aws_secret_access_key=%s' IGNOREHEADER 2 EMPTYASNULL", stagingTableName, bucketName, accessId, secretKey ); - LOG.debug( copyFromS3 ); + logger.debug( copyFromS3 ); con.createStatement().execute( copyFromS3 ); // run update portion of upsert process - LOG.info( "Upsert: updating" ); + logger.info( "Upsert: updating" ); String upsertUpdate = String.format( "UPDATE %s SET id = s.id FROM %s s WHERE %s.created = s.created ", mainTableName, stagingTableName, mainTableName ); - LOG.debug( upsertUpdate ); + logger.debug( upsertUpdate ); con.createStatement().execute( upsertUpdate ); // insert new values in staging table into main table - LOG.info( "Upsert: inserting" ); + logger.info( "Upsert: inserting" ); String upsertInsert = String.format( "INSERT INTO %s SELECT s.* FROM %s s LEFT JOIN %s n ON s.id = n.id WHERE n.id IS NULL", mainTableName, stagingTableName, mainTableName ); - LOG.debug( upsertInsert ); + logger.debug( upsertInsert ); con.createStatement().execute( upsertInsert ); // drop staging table - LOG.info( "Dropping existing staging table" ); + logger.info( "Dropping existing staging table" ); con.createStatement().execute( dropStagingTable ); // done! http://git-wip-us.apache.org/repos/asf/usergrid/blob/bc33c88d/stack/websocket/src/main/java/org/apache/usergrid/websocket/WebSocketChannelHandler.java ---------------------------------------------------------------------- diff --git a/stack/websocket/src/main/java/org/apache/usergrid/websocket/WebSocketChannelHandler.java b/stack/websocket/src/main/java/org/apache/usergrid/websocket/WebSocketChannelHandler.java index 63d76a4..91ca42f 100644 --- a/stack/websocket/src/main/java/org/apache/usergrid/websocket/WebSocketChannelHandler.java +++ b/stack/websocket/src/main/java/org/apache/usergrid/websocket/WebSocketChannelHandler.java @@ -81,7 +81,7 @@ import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1; public class WebSocketChannelHandler extends SimpleChannelUpstreamHandler { - private static final Logger LOG = LoggerFactory.getLogger( WebSocketChannelHandler.class ); + private static final Logger logger = LoggerFactory.getLogger( WebSocketChannelHandler.class ); private final EntityManagerFactory emf; private final ServiceManagerFactory smf; @@ -144,7 +144,7 @@ public class WebSocketChannelHandler extends SimpleChannelUpstreamHandler { } String location = ( ssl ? "wss://" : "ws://" ) + req.getHeader( HttpHeaders.Names.HOST ) + ( path != null ? path : "" ); - LOG.info( location ); + logger.info( location ); return location; } @@ -171,7 +171,7 @@ public class WebSocketChannelHandler extends SimpleChannelUpstreamHandler { @Override public void exceptionCaught( ChannelHandlerContext ctx, ExceptionEvent e ) { - LOG.warn( "Unexpected exception from downstream.", e.getCause() ); + logger.warn( "Unexpected exception from downstream.", e.getCause() ); e.getChannel().close(); } @@ -180,7 +180,7 @@ public class WebSocketChannelHandler extends SimpleChannelUpstreamHandler { public void channelDisconnected( ChannelHandlerContext ctx, ChannelStateEvent e ) throws Exception { super.channelDisconnected( ctx, e ); if ( websocket ) { - LOG.info( "Websocket disconnected" ); + logger.info( "Websocket disconnected" ); } } @@ -224,7 +224,7 @@ public class WebSocketChannelHandler extends SimpleChannelUpstreamHandler { else if ( is_ws_request ) { // Serve the WebSocket handshake request. - LOG.info( "Starting new websocket connection..." ); + logger.info( "Starting new websocket connection..." ); websocket = true; // Create the WebSocket handshake response. @@ -235,7 +235,7 @@ public class WebSocketChannelHandler extends SimpleChannelUpstreamHandler { QueryStringDecoder qs = new QueryStringDecoder( req.getUri() ); String path = qs.getPath(); - LOG.info( path ); + logger.info( path ); // Fill in the headers and contents depending on handshake method. if ( req.containsHeader( SEC_WEBSOCKET_KEY1 ) && req.containsHeader( SEC_WEBSOCKET_KEY2 ) ) { @@ -243,7 +243,7 @@ public class WebSocketChannelHandler extends SimpleChannelUpstreamHandler { String[] segments = split( path, '/' ); if ( segments.length != 3 ) { - LOG.info( "Wrong number of path segments, expected 3, found " + segments.length ); + logger.info( "Wrong number of path segments, expected 3, found " + segments.length ); sendHttpResponse( ctx, req, FORBIDDEN ); return; } @@ -252,7 +252,7 @@ public class WebSocketChannelHandler extends SimpleChannelUpstreamHandler { String collStr = segments[1]; String idStr = segments[2]; - LOG.info( nsStr + "/" + collStr + "/" + idStr ); + logger.info( nsStr + "/" + collStr + "/" + idStr ); if ( isEmpty( nsStr ) || isEmpty( collStr ) || isEmpty( idStr ) ) { sendHttpResponse( ctx, req, FORBIDDEN );
