Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

Commit

Permalink
USERGRID-1243: logging overhaul, pt. 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Dunker committed Jan 30, 2016
1 parent 0d4c35f commit 71fb610
Show file tree
Hide file tree
Showing 131 changed files with 857 additions and 756 deletions.
Expand Up @@ -211,8 +211,8 @@ public List<JobDescriptor> getJobs( int size ) {
// exception here. We don't want to cause job loss, so leave the job in
// the Q.
logger.error(
"Unable to retrieve job data for jobname {}, job id {}, stats id {}. Skipping to avoid job "
+ "loss", new Object[] { jobName, jobUuid, statsUuid, e } );
"Unable to retrieve job data for jobname {}, job id {}, stats id {}. Skipping to avoid job loss",
jobName, jobUuid, statsUuid, e );
}
}

Expand Down
Expand Up @@ -55,25 +55,25 @@ public void destroy() {
@Override
public void instanceCreated( InstanceEvent event ) {
Instance instance = event.getInstance();
logger.info( "Created instance ID: [" + instance.getId() + "] Type: [" + instance.getInstanceType() + "]" );
logger.info( "Created instance ID: [{}] Type: [{}]", instance.getId(), instance.getInstanceType() );
}


@Override
public void instanceDestroyed( InstanceEvent event ) {
Instance instance = event.getInstance();
logger.info( "Destroyed isntance ID: [" + instance.getId() + "] Type: [" + instance.getInstanceType() + "]" );
logger.info( "Destroyed instance ID: [{}] Type: [{}]", instance.getId(), instance.getInstanceType() );
}


@Override
public void memberAdded( MembershipEvent membersipEvent ) {
logger.info( "MemberAdded " + membersipEvent );
logger.info( "MemberAdded {}", membersipEvent );
}


@Override
public void memberRemoved( MembershipEvent membersipEvent ) {
logger.info( "MemberRemoved " + membersipEvent );
logger.info( "MemberRemoved {}", membersipEvent );
}
}
Expand Up @@ -443,9 +443,7 @@ public Entity get( EntityRef entityRef ) throws Exception {
if ( cpEntity == null ) {
if ( logger.isDebugEnabled() ) {
logger.debug( "FAILED to load entity {}:{} from app {}",
new Object[] {
id.getType(), id.getUuid(), applicationId
} );
id.getType(), id.getUuid(), applicationId );
}
return null;
}
Expand All @@ -466,7 +464,7 @@ public <A extends Entity> A get( UUID entityId, Class<A> entityClass ) throws Ex
}
catch ( ClassCastException e1 ) {
logger.error( "Unable to get typed entity: {} of class {}",
new Object[] { entityId, entityClass.getCanonicalName(), e1 } );
entityId, entityClass.getCanonicalName(), e1 );
}
return e;
}
Expand Down Expand Up @@ -500,9 +498,8 @@ public <A extends Entity> A getEntity( UUID entityId, Class<A> entityClass ) thr
if ( cpEntity == null ) {
if ( logger.isDebugEnabled() ) {
logger.debug( "FAILED to load entity {}:{} from app {}\n",
new Object[] {
id.getType(), id.getUuid(), applicationId
} );
);
}
return null;
}
Expand Down Expand Up @@ -558,11 +555,9 @@ public void update( Entity entity ) throws Exception {

if ( logger.isDebugEnabled() ) {
logger.debug( "Updating entity {}:{} app {}\n",
new Object[] {
entityId.getType(),
entityId.getUuid(),
appId
} );
appId );
}

// if ( !UUIDUtils.isTimeBased( entityId.getUuid() ) ) {
Expand All @@ -588,9 +583,9 @@ public void update( Entity entity ) throws Exception {
// cpEntity = ecm.load( entityId ).toBlockingObservable().last();

if (logger.isDebugEnabled()) {
logger.debug("Wrote {}:{} version {}", new Object[]{
logger.debug("Wrote {}:{} version {}",
cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
});
);
}
}
catch ( WriteUniqueVerifyException wuve ) {
Expand Down Expand Up @@ -686,14 +681,14 @@ public void decrementEntityCollection( String collection_name, long cassandraTim
}
catch ( Exception e ) {
logger.error( "Unable to decrement counter application.collection: {}.",
new Object[] { collection_name, e } );
collection_name, e );
}
try {
incrementAggregateCounters( null, null, null, APPLICATION_ENTITIES, -ONE_COUNT, cassandraTimestamp );
}
catch ( Exception e ) {
logger.error( "Unable to decrement counter application.entities for collection: {} " + "with timestamp: {}",
new Object[] { collection_name, cassandraTimestamp, e } );
logger.error( "Unable to decrement counter application.entities for collection: {} with timestamp: {}",
collection_name, cassandraTimestamp, e );
}
}

Expand Down Expand Up @@ -851,8 +846,8 @@ public EntityRef getAlias( EntityRef ownerRef, String collectionType, String ali
Assert.notNull( collectionType, "collectionType is required" );
Assert.notNull( aliasValue, "aliasValue is required" );

if (logger.isDebugEnabled()) {
logger.debug("getAlias() for collection type {} alias {}", collectionType, aliasValue);
if (logger.isTraceEnabled()) {
logger.trace("getAlias() for collection type {} alias {}", collectionType, aliasValue);
}

String collName = Schema.defaultCollectionName( collectionType );
Expand All @@ -866,9 +861,8 @@ public EntityRef getAlias( EntityRef ownerRef, String collectionType, String ali
// add a warn statement so we can see if we have data migration issues.
// TODO When we get an event system, trigger a repair if this is detected
if ( results.size() > 1 ) {
logger.warn( "More than 1 entity with Owner id '{}' of type '{}' "
+ "and alias '{}' exists. This is a duplicate alias, and needs audited",
new Object[] { ownerRef, collectionType, aliasValue } );
logger.warn( "More than 1 entity with Owner id '{}' of type '{}' and alias '{}' exists. This is a duplicate alias, and needs audited",
ownerRef, collectionType, aliasValue );
}

return results.get(aliasValue);
Expand All @@ -888,8 +882,8 @@ public Map<String, EntityRef> getAlias( String aliasType, List<String> aliases )
public Map<String, EntityRef> getAlias( EntityRef ownerRef, String collName, List<String> aliases )
throws Exception {

if (logger.isDebugEnabled()) {
logger.debug("getAliases() for collection {} aliases {}", collName, aliases);
if (logger.isTraceEnabled()) {
logger.trace("getAliases() for collection {} aliases {}", collName, aliases);
}

Assert.notNull( ownerRef, "ownerRef is required" );
Expand Down Expand Up @@ -946,8 +940,8 @@ public EntityRef validate( EntityRef entityRef, boolean verify ) throws Exceptio
get( entityRef ).getType();
}
catch ( Exception e ) {
logger.error( "Unable to load entity " + entityRef.getType()
+ ":" + entityRef.getUuid(), e );
logger.error( "Unable to load entity {}:{}", entityRef.getType(),
entityRef.getUuid(), e );
}
if ( entityRef == null ) {
throw new EntityNotFoundException(
Expand Down Expand Up @@ -1075,19 +1069,17 @@ public void deleteProperty( EntityRef entityRef, String propertyName ) throws Ex

cpEntity.removeField( propertyName );

if(logger.isDebugEnabled()){
logger.debug( "About to Write {}:{} version {}", new Object[] {
cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
} );
if(logger.isTraceEnabled()){
logger.trace( "About to Write {}:{} version {}",
cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion() );
}

//TODO: does this call and others like it need a graphite reporter?
cpEntity = ecm.write( cpEntity ).toBlocking().last();

if(logger.isDebugEnabled()){
logger.debug("Wrote {}:{} version {}", new Object[]{
cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
});
if(logger.isTraceEnabled()){
logger.trace("Wrote {}:{} version {}",
cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion() );
}

//Adding graphite metrics
Expand Down Expand Up @@ -1820,7 +1812,7 @@ public Entity createGroupRole( UUID groupId, String roleName, long inactivity )
.addToCollection( COLLECTION_ROLES, entity );

logger.info( "Created role {} with id {} in group {}",
new String[] { roleName, entity.getUuid().toString(), groupId.toString() } );
roleName, entity.getUuid().toString(), groupId.toString() );

return entity;
}
Expand Down Expand Up @@ -2160,8 +2152,8 @@ public EntityRef getUserByIdentifier( Identifier identifier ) throws Exception {
return null;
}

if(logger.isDebugEnabled()){
logger.debug( "getUserByIdentifier {}:{}", identifier.getType(), identifier.toString() );
if(logger.isTraceEnabled()){
logger.trace( "getUserByIdentifier {}:{}", identifier.getType(), identifier.toString() );
}

if ( identifier.isUUID() ) {
Expand Down Expand Up @@ -2608,32 +2600,28 @@ else if ( ( v instanceof String ) && isBlank( ( String ) v ) ) {

// prepare to write and index Core Persistence Entity into default scope

if ( logger.isDebugEnabled() ) {
logger.debug( "Writing entity {}:{} into app {}\n",
new Object[] {
if ( logger.isTraceEnabled() ) {
logger.trace( "Writing entity {}:{} into app {}\n",
entity.getType(),
entity.getUuid(),
applicationId,
CpEntityMapUtils.toMap( cpEntity )
} );
CpEntityMapUtils.toMap( cpEntity ));

}

try {

if(logger.isDebugEnabled()) {
logger.debug( "About to Write {}:{} version {}", new Object[] {
cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
} );
if(logger.isTraceEnabled()) {
logger.trace( "About to Write {}:{} version {}",
cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion() );
}

cpEntity = ecm.write( cpEntity ).toBlocking().last();
entity.setSize(cpEntity.getSize());

if(logger.isDebugEnabled()) {
logger.debug( "Wrote {}:{} version {}", new Object[] {
cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
} );
if(logger.isTraceEnabled()) {
logger.trace( "Wrote {}:{} version {}",
cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion() );
}

}
Expand Down Expand Up @@ -2672,16 +2660,15 @@ private void incrementEntityCollection( String collection_name, long cassandraTi
}
catch ( Exception e ) {
logger.error( "Unable to increment counter application.collection: {}.",
new Object[] { collection_name, e } );
collection_name, e );
}
try {
incrementAggregateCounters( null, null, null,
APPLICATION_ENTITIES, ONE_COUNT, cassandraTimestamp );
}
catch ( Exception e ) {
logger.error( "Unable to increment counter application.entities for collection: "
+ "{} with timestamp: {}",
new Object[] { collection_name, cassandraTimestamp, e } );
logger.error( "Unable to increment counter application.entities for collection: {} with timestamp: {}",
collection_name, cassandraTimestamp, e );
}
}

Expand Down
Expand Up @@ -226,7 +226,7 @@ public Entity createApplicationV2(

if (logger.isDebugEnabled()) {
logger.debug("New application orgName {} orgAppName {} id {} ",
new Object[]{orgName, name, applicationId.toString()});
orgName, name, applicationId.toString());
}

return initializeApplicationV2( orgName, applicationId, appName, properties, forMigration);
Expand Down Expand Up @@ -481,7 +481,7 @@ private Map<String, UUID> getApplications(final String edgeType) throws Exceptio

if (logger.isDebugEnabled()) {
logger.debug("getApplications(): Loading edges of edgeType {} from {}:{}",
new Object[]{edgeType, managementId.getType(), managementId.getUuid()});
edgeType, managementId.getType(), managementId.getUuid());
}

Observable<MarkedEdge> edges = gm.loadEdgesFromSource(
Expand Down Expand Up @@ -621,7 +621,7 @@ public boolean deleteServiceProperty(String name) {
results = em.searchCollection( em.getApplicationRef(), "propertymaps", q);

} catch (Exception ex) {
logger.error("Error getting service property for delete of property: " + name, ex);
logger.error("Error getting service property for delete of property: {}", name, ex);
return false;
}

Expand All @@ -639,7 +639,7 @@ public boolean deleteServiceProperty(String name) {
em.update( propsEntity );

} catch (Exception ex) {
logger.error("Error deleting service property orgAppName: " + name, ex);
logger.error("Error deleting service property orgAppName: {}", name, ex);
return false;
}

Expand Down

0 comments on commit 71fb610

Please sign in to comment.