use of com.redhat.jenkins.plugins.ci.messaging.JMSMessagingProvider in project jms-messaging-plugin by jenkinsci.
the class CIBuildTrigger method startTriggerThreads.
private void startTriggerThreads() {
if (job == null)
return;
if (providerUpdated) {
log.info("Saving job since messaging provider was migrated...");
try {
job.save();
} catch (IOException e) {
log.warning("Exception while trying to save job: " + e.getMessage());
}
}
if (job instanceof AbstractProject) {
AbstractProject<?, ?> aJob = (AbstractProject<?, ?>) job;
if (aJob.isDisabled()) {
log.info("Job '" + job.getFullName() + "' is disabled, not subscribing.");
return;
}
}
try {
synchronized (locks.computeIfAbsent(job.getFullName(), o -> new ArrayList<>())) {
if (stopTriggerThreads(job.getFullName()) == null && providers != null) {
List<CITriggerThread> threads = locks.get(job.getFullName());
int instance = 1;
for (ProviderData pd : providers) {
JMSMessagingProvider provider = GlobalCIConfiguration.get().getProvider(pd.getName());
if (provider == null) {
log.log(Level.SEVERE, "Failed to locate JMSMessagingProvider with name " + pd.getName() + ". You must update the job configuration. Trigger not started.");
return;
}
CITriggerThread thread = CITriggerThreadFactory.createCITriggerThread(provider, pd, job.getFullName(), this, instance);
log.info("Starting thread (" + thread.getId() + ") for '" + job.getFullName() + "'.");
thread.start();
threads.add(thread);
instance++;
}
}
}
} catch (Exception e) {
log.log(Level.SEVERE, "Unhandled exception in trigger start.", e);
}
}
use of com.redhat.jenkins.plugins.ci.messaging.JMSMessagingProvider in project jms-messaging-plugin by jenkinsci.
the class CIBuildTrigger method readResolve.
@Override
protected Object readResolve() {
if (providers == null) {
log.info("Migrating CIBuildTrigger for job '" + getJobName() + "'.");
providers = new ArrayList<>();
if (providerData == null) {
if (providerName == null) {
log.info("Provider is null for trigger for job '" + getJobName() + "'.");
JMSMessagingProvider provider = GlobalCIConfiguration.get().getConfigs().get(0);
if (provider != null) {
providerName = provider.getName();
providerUpdated = true;
saveJob();
}
}
JMSMessagingProvider provider = GlobalCIConfiguration.get().getProvider(providerName);
if (provider != null) {
if (provider instanceof ActiveMqMessagingProvider) {
log.info("Creating '" + providerName + "' trigger provider data for job '" + getJobName() + "'.");
ActiveMQSubscriberProviderData a = new ActiveMQSubscriberProviderData(providerName);
a.setSelector(selector);
a.setOverrides(overrides);
a.setChecks(checks);
providers.add(a);
providerUpdated = true;
saveJob();
} else if (provider instanceof FedMsgMessagingProvider) {
log.info("Creating '" + providerName + "' trigger provider data for job '" + getJobName() + "'.");
FedMsgSubscriberProviderData f = new FedMsgSubscriberProviderData(providerName);
f.setOverrides(overrides);
f.setChecks(checks);
providers.add(f);
providerUpdated = true;
saveJob();
}
} else {
log.warning("Unable to find provider '" + providerName + "', so unable to upgrade job.");
}
} else {
providers.add(providerData);
providerUpdated = true;
saveJob();
}
}
return this;
}
use of com.redhat.jenkins.plugins.ci.messaging.JMSMessagingProvider in project jms-messaging-plugin by jenkinsci.
the class CIBuildTrigger method getComparisonThreads.
private List<CITriggerThread> getComparisonThreads() {
if (providers != null && job != null) {
List<CITriggerThread> threads = new ArrayList<>();
int instance = 1;
for (ProviderData pd : providers) {
JMSMessagingProvider provider = GlobalCIConfiguration.get().getProvider(pd.getName());
// The thread is never started.
if (provider == null)
throw new NullPointerException("No such provider configured for name: '" + pd.getName() + "' on job named '" + job.getFullName() + "'");
CITriggerThread thread = new CITriggerThread(provider, pd, job.getFullName(), null, instance);
threads.add(thread);
instance++;
}
return threads;
}
return null;
}
Aggregations