List of usage examples for org.apache.commons.logging Log debug
void debug(Object message);
From source file:org.openspaces.grid.gsm.rebalancing.RebalancingUtils.java
static FutureStatefulProcessingUnitInstance relocateProcessingUnitInstanceAsync( final GridServiceContainer targetContainer, final ProcessingUnitInstance puInstance, final Log logger, final long duration, final TimeUnit timeUnit) { final ProcessingUnit pu = puInstance.getProcessingUnit(); final GridServiceContainer[] replicationSourceContainers = getReplicationSourceContainers(puInstance); final int instanceId = puInstance.getInstanceId(); final AtomicReference<Throwable> relocateThrowable = new AtomicReference<Throwable>(); final Admin admin = puInstance.getAdmin(); final int runningNumber = puInstance.getClusterInfo().getRunningNumber(); final String puName = puInstance.getName(); final GridServiceContainer sourceContainer = puInstance.getGridServiceContainer(); final Set<ProcessingUnitInstance> puInstancesFromSamePartition = getOtherInstancesFromSamePartition( puInstance);/*from w w w . j ava 2 s . c o m*/ if (logger.isDebugEnabled()) { logger.debug( "Found instances from the same partition as " + RebalancingUtils.puInstanceToString(puInstance) + " : " + RebalancingUtils.puInstancesToString(puInstancesFromSamePartition)); } if (puInstancesFromSamePartition.size() != pu.getNumberOfBackups()) { // total number of instances per partition = numberOfBackups + 1 throw new IllegalStateException("puInstancesFromSamePartition has " + puInstancesFromSamePartition.size() + " instances instead of " + pu.getNumberOfBackups()); } final long start = System.currentTimeMillis(); final long end = start + timeUnit.toMillis(duration); ((InternalAdmin) admin).scheduleAdminOperation(new Runnable() { public void run() { try { logger.debug("Relocation of " + RebalancingUtils.puInstanceToString(puInstance) + " to " + ContainersSlaUtils.gscToString(targetContainer) + " has started."); puInstance.relocate(targetContainer); } catch (AdminException e) { logger.error("Admin exception " + e.getMessage(), e); relocateThrowable.set(e); } catch (Throwable e) { logger.error("Unexpected exception " + e.getMessage(), e); relocateThrowable.set(e); } } }); return new FutureStatefulProcessingUnitInstance() { Throwable throwable; ProcessingUnitInstance newInstance; public boolean isTimedOut() { return System.currentTimeMillis() > end; } public boolean isDone() { endRelocation(); return isTimedOut() || throwable != null || newInstance != null; } public ProcessingUnitInstance get() throws ExecutionException, IllegalStateException, TimeoutException { endRelocation(); ExecutionException exception = getException(); if (exception != null) { throw exception; } if (newInstance == null) { if (isTimedOut()) { throw new TimeoutException("Relocation timeout"); } throw new IllegalStateException("Async operation is not done yet."); } return newInstance; } public Date getTimestamp() { return new Date(start); } public ExecutionException getException() { endRelocation(); if (throwable != null) { return new ExecutionException(throwable.getMessage(), throwable); } return null; } /** * populates this.exception or this.newInstance if relocation is complete */ private void endRelocation() { boolean inProgress = true; tryStateChange(); // this makes relocation synchronous if (newInstance != null || throwable != null) { inProgress = false; } if (inProgress) { if (logger.isDebugEnabled()) { logger.debug("Relocation from " + ContainersSlaUtils.gscToString(getSourceContainer()) + " to " + ContainersSlaUtils.gscToString(getTargetContainer()) + " is in progress."); } // do nothing. relocate() method running on another thread has not returned yet. } } private void tryStateChange() { ProcessingUnitInstance relocatedInstance = getRelocatedProcessingUnitInstance(); if (relocatedInstance != null) { if (relocatedInstance.getGridServiceContainer().equals(targetContainer)) { if (relocatedInstance.getSpaceInstance() != null && relocatedInstance.getSpaceInstance().getMode() != SpaceMode.NONE) { if (logger.isDebugEnabled()) { logger.debug( "Relocation from " + ContainersSlaUtils.gscToString(getSourceContainer()) + " to " + ContainersSlaUtils.gscToString(getTargetContainer()) + " had ended successfully."); } newInstance = relocatedInstance; } } else { if (logger.isDebugEnabled()) { logger.debug("Relocation from " + ContainersSlaUtils.gscToString(getSourceContainer()) + " to " + ContainersSlaUtils.gscToString(getTargetContainer()) + " has ended with an error."); } throwable = new WrongContainerProcessingUnitRelocationException(puInstance, targetContainer); } } } private ProcessingUnitInstance getRelocatedProcessingUnitInstance() { for (GridServiceContainer container : admin.getGridServiceContainers()) { for (ProcessingUnitInstance instance : container.getProcessingUnitInstances(puName)) { if (!instance.equals(puInstance) && instance.getClusterInfo().getRunningNumber() == runningNumber && !puInstancesFromSamePartition.contains(instance)) { return instance; } } } return null; } private boolean isAtLeastOneInstanceValid(Set<ProcessingUnitInstance> instances) { boolean isValidState = false; for (ProcessingUnitInstance instance : instances) { if (instance.isDiscovered() && instance.getGridServiceContainer().isDiscovered()) { isValidState = true; break; } } return isValidState; } public String getFailureMessage() { if (isTimedOut()) { return "relocation timeout of processing unit instance " + instanceId + " from " + gscToString(sourceContainer) + " to " + gscToString(targetContainer); } if (getException() != null) { return getException().getMessage(); } throw new IllegalStateException("Relocation has not encountered any failure."); } public GridServiceContainer getTargetContainer() { return targetContainer; } public ProcessingUnit getProcessingUnit() { return pu; } public int getInstanceId() { return instanceId; } public GridServiceContainer getSourceContainer() { return sourceContainer; } public GridServiceContainer[] getReplicaitonSourceContainers() { return replicationSourceContainers; } }; }
From source file:org.ops4j.gaderian.service.impl.AssemblyInstructionImpl.java
private void autowireService(Object service, String propertyName, AssemblyParameters factoryParameters) { Class propertyType = PropertyUtils.getPropertyType(service, propertyName); final Module invokingModule = factoryParameters.getInvokingModule(); final Log log = factoryParameters.getLog(); try {/*from w w w . j av a2s .c om*/ // Ignore properties for which there are no corresponding // service points... if (invokingModule.containsService(propertyType)) { Object collaboratingService = invokingModule.getService(propertyType); PropertyUtils.write(service, propertyName, collaboratingService); if (log.isDebugEnabled()) { log.debug("Autowired service property " + propertyName + " to " + collaboratingService); } } } catch (Exception ex) { invokingModule.getErrorHandler().error(log, ServiceMessages.autowirePropertyFailure(propertyName, factoryParameters.getServiceId(), ex), getLocation(), ex); } }
From source file:org.ops4j.gaderian.service.impl.BuilderFacet.java
/** * Wire (or auto-wire) the property; return the name of the property actually set (if a property * is set, which is not always the case). *///ww w . j a v a 2 s . c om public String wireProperty(Object service, AssemblyParameters assemblyParameters) { try { // Autowire the property (if possible). String autowirePropertyName = autowire(service, assemblyParameters); if (autowirePropertyName != null) return autowirePropertyName; // There will be a facet for log, messages, service-id, etc. even if no // property name is specified, so we skip it here. In many cases, those // facets will have just done an autowire. if (_propertyName == null) return null; Class targetType = PropertyUtils.getPropertyType(service, _propertyName); Object value = getFacetValue(assemblyParameters, targetType); PropertyUtils.write(service, _propertyName, value); final Log log = assemblyParameters.getLog(); if (log.isDebugEnabled()) log.debug("Set property " + _propertyName + " to " + value); return _propertyName; } catch (Exception ex) { assemblyParameters.getErrorLog().error(ex.getMessage(), getLocation(), ex); return null; } }
From source file:org.ops4j.gaderian.service.impl.BuilderFacet.java
/** * Attempts to autowire a property of the target. This requires that * <ul>//from www . ja v a 2 s .c om * <li>The facet type defines a default property name and facet type * <li>The facet instance does not have a specified property name * <li>The (default) property is writeable * <li>The (default) property is assignable from the facet type * </ul> * If all conditions are met, then the property is updated to the facet value, and the property * name is returned. In all other cases, null is returned. * * @param target * The service implementation being constructed * @param assemblyParameters * the parameters that define the service point and its environment */ private String autowire(Object target, AssemblyParameters assemblyParameters) { if (_propertyName != null) return null; String defaultPropertyName = getDefaultPropertyName(); if (defaultPropertyName == null) return null; if (!PropertyUtils.isWritable(target, defaultPropertyName)) return null; Class propertyType = PropertyUtils.getPropertyType(target, defaultPropertyName); if (isAssignableToType(assemblyParameters, propertyType)) { Object facetValue = getFacetValue(assemblyParameters, propertyType); PropertyUtils.write(target, defaultPropertyName, facetValue); Log log = assemblyParameters.getLog(); if (log.isDebugEnabled()) log.debug("Autowired property " + defaultPropertyName + " to " + facetValue); return defaultPropertyName; } return null; }
From source file:org.ops4j.gaderian.service.impl.LoggingUtils.java
public static void entry(Log log, String methodName, Object[] args) { StringBuffer buffer = new StringBuffer(BUFFER_SIZE); buffer.append("BEGIN "); buffer.append(methodName);//from ww w .j a v a2 s. c o m buffer.append("("); int count = (args == null) ? 0 : args.length; for (int i = 0; i < count; i++) { Object arg = args[i]; if (i > 0) buffer.append(", "); convert(buffer, arg); } buffer.append(")"); log.debug(buffer.toString()); }
From source file:org.ops4j.gaderian.service.impl.LoggingUtils.java
public static void exit(Log log, String methodName, Object result) { StringBuffer buffer = new StringBuffer(BUFFER_SIZE); buffer.append("END "); buffer.append(methodName);//from w w w.j av a 2 s. c o m buffer.append("() ["); convert(buffer, result); buffer.append("]"); log.debug(buffer.toString()); }
From source file:org.ops4j.gaderian.service.impl.LoggingUtils.java
public static void voidExit(Log log, String methodName) { StringBuffer buffer = new StringBuffer(BUFFER_SIZE); buffer.append("END "); buffer.append(methodName);//ww w . j av a 2 s . co m buffer.append("()"); log.debug(buffer.toString()); }
From source file:org.ops4j.gaderian.service.impl.TestLoggingInterceptorFactory.java
/** * A test for HIVEMIND-55 ... ensure that the LoggingInterceptor can work on * top of a JDK proxy./*w ww. jav a 2s .c o m*/ */ public void testLoggingOverProxy() { ClassFactory cf = new ClassFactoryImpl(); Runnable r = (Runnable) createMock(Runnable.class); Log log = createMock(Log.class); LoggingInterceptorFactory f = new LoggingInterceptorFactory(); f.setFactory(cf); ServicePoint sp = createMock(ServicePoint.class); Module module = createMock(Module.class); // Training expect(sp.getServiceInterface()).andReturn(Runnable.class); expect(sp.getExtensionPointId()).andReturn("foo.bar"); replayAllRegisteredMocks(); InterceptorStackImpl is = new InterceptorStackImpl(log, sp, r); f.createInterceptor(is, module, Collections.EMPTY_LIST); Runnable ri = (Runnable) is.peek(); verifyAllRegisteredMocks(); // Training expect(log.isDebugEnabled()).andReturn(true); log.debug("BEGIN run()"); log.debug("END run()"); r.run(); replayAllRegisteredMocks(); ri.run(); verifyAllRegisteredMocks(); }
From source file:org.ops4j.gaderian.strategy.DateLoggingStrategy.java
public void log(Log log, Object message) { log.debug(MessageFormat.format("{0,date,MM/dd/yyyy}", new Object[] { message })); }
From source file:org.ops4j.gaderian.strategy.DefaultLoggingStrategy.java
public void log(Log log, Object message) { log.debug(String.valueOf(message)); }