mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
REPO-2853: Clean up
* Fix formatting * Add javadoc * Remove unused imports * Remove unused Heartbeat.isEnabled()
This commit is contained in:
committed by
Ancuta Morarasu
parent
c18d4cb4e6
commit
70a9a2dae3
@@ -27,7 +27,6 @@ package org.alfresco.heartbeat;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.heartbeat.datasender.HBData;
|
||||
import org.alfresco.heartbeat.datasender.HBDataSenderService;
|
||||
import org.alfresco.service.cmr.repository.HBDataCollectorService;
|
||||
@@ -39,12 +38,23 @@ public class HBDataCollectorServiceImpl implements HBDataCollectorService
|
||||
/** The logger. */
|
||||
private static final Log logger = LogFactory.getLog(HBDataCollectorServiceImpl.class);
|
||||
|
||||
/** List of collectors registered with this service */
|
||||
private List<HBBaseDataCollector> collectors = new LinkedList<>();
|
||||
|
||||
/** The service responsible for sending the collected data */
|
||||
private HBDataSenderService hbDataSenderService;
|
||||
|
||||
/** Current enabled state */
|
||||
private boolean enabled = false;
|
||||
|
||||
/** The default enable state */
|
||||
private final boolean defaultHbState;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param defaultHeartBeatState the default enabled state of heartbeat
|
||||
*
|
||||
*/
|
||||
public HBDataCollectorServiceImpl (boolean defaultHeartBeatState)
|
||||
{
|
||||
this.defaultHbState = defaultHeartBeatState;
|
||||
@@ -56,12 +66,22 @@ public class HBDataCollectorServiceImpl implements HBDataCollectorService
|
||||
this.hbDataSenderService = hbDataSenderService;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Register data collector with this service.
|
||||
* The registered collectors will be called to provide heartbeat data.
|
||||
*
|
||||
* @param collector collector to register
|
||||
*/
|
||||
@Override
|
||||
public void registerCollector(HBBaseDataCollector collector)
|
||||
{
|
||||
this.collectors.add(collector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects and sends data for all registered collectors using the provided sender service.
|
||||
*/
|
||||
@Override
|
||||
public void collectAndSendData()
|
||||
{
|
||||
@@ -74,7 +94,8 @@ public class HBDataCollectorServiceImpl implements HBDataCollectorService
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// log exception;
|
||||
// Log exception
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -49,8 +49,9 @@ import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* This class communicates some very basic repository statistics to Alfresco on a regular basis.
|
||||
* The class is responsible for scheduling the HeartBeat job and reacting to licence change events.
|
||||
*
|
||||
* @author dward
|
||||
* @author dward, eknizat
|
||||
*/
|
||||
public class HeartBeat implements LicenseChangeHandler
|
||||
{
|
||||
@@ -68,8 +69,6 @@ public class HeartBeat implements LicenseChangeHandler
|
||||
|
||||
private HBDataCollectorService dataCollectorService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialises the heart beat service. Note that dependencies are intentionally 'pulled' rather than injected
|
||||
* because we don't want these to be reconfigured.
|
||||
@@ -79,7 +78,7 @@ public class HeartBeat implements LicenseChangeHandler
|
||||
*/
|
||||
public HeartBeat(final ApplicationContext context)
|
||||
{
|
||||
this(context, true);
|
||||
this(context, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,8 +95,6 @@ public class HeartBeat implements LicenseChangeHandler
|
||||
{
|
||||
logger.debug("Initialising HeartBeat");
|
||||
|
||||
|
||||
// I think these should be wired by spring instead for proper ioc..
|
||||
this.dataCollectorService = (HBDataCollectorService) context.getBean("hbDataCollectorService");
|
||||
this.scheduler = (Scheduler) context.getBean("schedulerFactory");
|
||||
|
||||
@@ -130,26 +127,11 @@ public class HeartBeat implements LicenseChangeHandler
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return <tt>true</tt> if the heartbeat is currently enabled
|
||||
*/
|
||||
public synchronized boolean isEnabled()
|
||||
{
|
||||
return dataCollectorService.isHbEnabled();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sends encrypted data over HTTP.
|
||||
* Delegates data collection and sending to HBDataCollectorService.
|
||||
*
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
* @throws GeneralSecurityException
|
||||
* an encryption related exception
|
||||
*/
|
||||
public void collectAndSendData() throws IOException, GeneralSecurityException
|
||||
public void collectAndSendData()
|
||||
{
|
||||
this.dataCollectorService.collectAndSendData();
|
||||
}
|
||||
@@ -258,6 +240,4 @@ public class HeartBeat implements LicenseChangeHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -36,7 +36,6 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.alfresco.heartbeat.datasender.HBData;
|
||||
import org.alfresco.repo.descriptor.DescriptorDAO;
|
||||
import org.alfresco.repo.dictionary.CustomModelsInfo;
|
||||
@@ -47,11 +46,9 @@ import org.alfresco.service.cmr.dictionary.CustomModelService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.AuthorityType;
|
||||
import org.alfresco.service.descriptor.Descriptor;
|
||||
import org.alfresco.service.license.LicenseException;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.Base64;
|
||||
|
||||
public class RepositoryDataCollector extends HBBaseDataCollector
|
||||
{
|
||||
|
@@ -29,7 +29,6 @@ import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.heartbeat.HBBaseDataCollector;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
@@ -38,7 +37,6 @@ import org.alfresco.repo.usage.RepoUsageComponent;
|
||||
import org.alfresco.service.cmr.admin.RepoUsage;
|
||||
import org.alfresco.service.cmr.admin.RepoUsage.LicenseMode;
|
||||
import org.alfresco.service.cmr.admin.RepoUsage.UsageType;
|
||||
import org.alfresco.service.cmr.repository.HBDataCollectorService;
|
||||
import org.alfresco.service.descriptor.Descriptor;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.alfresco.service.license.LicenseDescriptor;
|
||||
|
Reference in New Issue
Block a user