Index: opencast-capture-admin-service-impl/src/main/java/org/opencastproject/capture/admin/impl/CaptureAgentStatusServiceImpl.java
===================================================================
--- opencast-capture-admin-service-impl/src/main/java/org/opencastproject/capture/admin/impl/CaptureAgentStatusServiceImpl.java (revision 893)
+++ opencast-capture-admin-service-impl/src/main/java/org/opencastproject/capture/admin/impl/CaptureAgentStatusServiceImpl.java (working copy)
@@ -39,12 +39,8 @@
private HashMap<String, Recording> recordings;
public CaptureAgentStatusServiceImpl() {
- if (agents == null) {
- agents = new HashMap<String, Agent>();
- }
- if (recordings == null) {
- recordings = new HashMap<String, Recording>();
- }
+ agents = new HashMap<String, Agent>();
+ recordings = new HashMap<String, Recording>();
}
/**
Index: opencast-capture-service-api/src/main/java/org/opencastproject/capture/api/Scheduler.java
===================================================================
--- opencast-capture-service-api/src/main/java/org/opencastproject/capture/api/Scheduler.java (revision 887)
+++ opencast-capture-service-api/src/main/java/org/opencastproject/capture/api/Scheduler.java (working copy)
@@ -58,7 +58,7 @@
* Gets the time between refreshes of the scheduling data
* @return The time between refreshes of the scheduling data
*/
- public int getPollingTime();
+ public long getPollingTime();
/**
* Enables polling for new calendar data
Index: opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/SchedulerImpl.java
===================================================================
--- opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/SchedulerImpl.java (revision 887)
+++ opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/SchedulerImpl.java (working copy)
@@ -74,7 +74,7 @@
private URL localCalendarCacheURL = null;
/** The time in milliseconds between attempts to fetch the calendar data */
- private int pollTime = 0;
+ private long pollTime = 0;
/** A stored copy of the Calendar at the URI */
private Calendar calendar = null;
@@ -102,7 +102,8 @@
try {
remoteCalendarURL = new URL(config.getItem(CaptureParameters.CAPTURE_SCHEDULE_URL));
- pollTime = Integer.parseInt(config.getItem(CaptureParameters.CAPTURE_SCHEDULE_POLLING_INTERVAL));
+ //Times are in seconds in the config file, so multiply by 1000
+ pollTime = Long.parseLong(config.getItem(CaptureParameters.CAPTURE_SCHEDULE_POLLING_INTERVAL)) * 1000L;
if (pollTime > 1) {
//Load the properties for this scheduler. Each scheduler requires its own unique properties file.
pollingProperties = new Properties();
@@ -116,7 +117,7 @@
//Setup the polling
JobDetail job = new JobDetail("calendarUpdate", Scheduler.DEFAULT_GROUP, PollCalendarJob.class);
//Create a new trigger Name Group name Start End # of times to repeat Repeat interval
- SimpleTrigger trigger = new SimpleTrigger("polling", Scheduler.DEFAULT_GROUP, new Date(), null, SimpleTrigger.REPEAT_INDEFINITELY, pollTime * 1000L);
+ SimpleTrigger trigger = new SimpleTrigger("polling", Scheduler.DEFAULT_GROUP, new Date(), null, SimpleTrigger.REPEAT_INDEFINITELY, pollTime);
trigger.getJobDataMap().put(SCHEDULER, this);
@@ -508,7 +509,7 @@
* {@inheritDoc}
* @see org.opencastproject.capture.api.Scheduler#getPollingTime()
*/
- public int getPollingTime() {
+ public long getPollingTime() {
return pollTime;
}
Index: opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/ConfigurationManager.java
===================================================================
--- opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/ConfigurationManager.java (revision 887)
+++ opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/ConfigurationManager.java (working copy)
@@ -105,7 +105,8 @@
timer = new Timer();
long delay = 0;
try {
- delay = Long.parseLong(reload);
+ //Times in the config file are in seconds, so multiply by 1000
+ delay = Long.parseLong(reload) * 1000;
if (delay < 1) {
logger.info("Polling time has been set to less than 1 second, polling disabled");
return;
Index: opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/StatusServiceImpl.java
===================================================================
--- opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/StatusServiceImpl.java (revision 887)
+++ opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/StatusServiceImpl.java (working copy)
@@ -30,6 +30,7 @@
public class StatusServiceImpl implements StatusService, ManagedService {
private static final Logger logger = LoggerFactory.getLogger(StatusServiceImpl.class);
+ public static final String SERVICE = "StatusServiceImpl";
private String cur_status = null;
private ConfigurationManager config = null;
@@ -37,10 +38,39 @@
* Creates an instance of the status service, and sets its initial state to AgentState.IDLE
*/
public StatusServiceImpl() {
+ logger.info("Starting StatusServiceImpl");
if (cur_status == null) {
cur_status = AgentState.IDLE;
}
config = ConfigurationManager.getInstance();
+
+/* try {
+ long pollTime = Long.parseLong(config.getItem(CaptureParameters.AGENT_STATUS_POLLING_INTERVAL)) * 1000L;
+ Properties pollingProperties = new Properties();
+ pollingProperties.load(getClass().getClassLoader().getResourceAsStream("config/misc.properties"));
+ StdSchedulerFactory sched_fact = new StdSchedulerFactory(pollingProperties);
+
+ //Create and start the scheduler
+ Scheduler pollScheduler = sched_fact.getScheduler();
+ pollScheduler.start();
+
+ //Setup the polling
+ JobDetail job = new JobDetail("agentStatusUpdate", Scheduler.DEFAULT_GROUP, AgentStatusJob.class);
+ //TODO: Support changing the polling interval
+ //Create a new trigger Name Group name Start End # of times to repeat Repeat interval
+ SimpleTrigger trigger = new SimpleTrigger("status_polling", Scheduler.DEFAULT_GROUP, new Date(), null, SimpleTrigger.REPEAT_INDEFINITELY, pollTime);
+
+ trigger.getJobDataMap().put(SERVICE, this);
+
+ //Schedule the update
+ pollScheduler.scheduleJob(job, trigger);
+ } catch (NumberFormatException e) {
+ logger.error("Invalid time specified in the " + CaptureParameters.AGENT_STATUS_POLLING_INTERVAL + " value, unable to push status to remote server!");
+ } catch (IOException e) {
+ logger.error("IOException caught in StatusServiceImpl", e);
+ } catch (SchedulerException e) {
+ logger.error("SchedulerException in StatusServiceImpl", e);
+ }*/
}
/**
Index: opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/CaptureParameters.java
===================================================================
--- opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/CaptureParameters.java (revision 887)
+++ opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/CaptureParameters.java (working copy)
@@ -59,4 +59,19 @@
/** The local URL of the cached copy of the capture schedule */
public static final String CAPTURE_SCHEDULE_CACHE_URL = "capture.schedule.cache.url";
+
+ /** The name of the agent */
+ public static final String AGENT_NAME = "capture.agent.name";
+
+ /** The URL of the remote status service */
+ public static final String AGENT_STATUS_ENDPOINT_URL = "capture.agent.status.endpoint.url";
+
+ /** The time between attempts to push the agent's status to the status service */
+ public static final String AGENT_STATUS_POLLING_INTERVAL = "capture.agent.status.polling.interval";
+
+ /** The URL of the remote recording status service */
+ public static final String RECORDING_STATUS_ENDPOINT_URL = "capture.recording.status.endpoint.url";
+
+ /** The time between attemps to push the current recording's status to the status service */
+ public static final String RECORDING_STATUS_POLLING_INTERVAL = "capture.recording.status.polling.interval";
}
Index: opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/Activator.java
===================================================================
--- opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/Activator.java (revision 887)
+++ opencast-capture-service-impl/src/main/java/org/opencastproject/capture/impl/Activator.java (working copy)
@@ -31,6 +31,7 @@
private static final Logger log = LoggerFactory.getLogger(Activator.class);
private BundleContext context;
private Scheduler sched;
+ //private StatusService service;
/**
* {@inheritDoc}
@@ -39,8 +40,9 @@
public void start(BundleContext context) throws Exception {
createCoreDirectories(ConfigurationManager.getInstance());
this.context = context;
- sched = new SchedulerImpl();
- sched.init();
+ //service = new StatusServiceImpl();
+// sched = new SchedulerImpl();
+// sched.init();
}
/**
Index: opencast-capture-service-impl/src/main/resources/config/capture.cfg
===================================================================
--- opencast-capture-service-impl/src/main/resources/config/capture.cfg (revision 896)
+++ opencast-capture-service-impl/src/main/resources/config/capture.cfg (working copy)
@@ -13,6 +13,7 @@
capture.config.polling.interval=600
capture.config.cache.url=/opencast/cache/capture.cfg
+capture.agent.name=agent1
capture.agent.status.endpoint.url=http://localhost:8080/capture-admin/rest/SetAgentState
capture.agent.status.polling.interval=60
Index: opencast-capture-service-impl/pom.xml
===================================================================
--- opencast-capture-service-impl/pom.xml (revision 887)
+++ opencast-capture-service-impl/pom.xml (working copy)
@@ -123,6 +123,21 @@
<artifactId>ical4j</artifactId>
<version>1.0-rc1</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpmime</artifactId>
+ <version>4.0</version>
+ </dependency>
</dependencies>
<build>
<plugins>