Skip to content

Commit

Permalink
Merge pull request #2524 from eclipse/feature-deviceJobDeployV2Improv…
Browse files Browse the repository at this point in the history
…ements

Device job deploy v2 improvements
  • Loading branch information
Coduz authored Jun 21, 2019
2 parents 35b78c3 + 879ba8c commit 33d63bb
Show file tree
Hide file tree
Showing 88 changed files with 2,659 additions and 261 deletions.
11 changes: 11 additions & 0 deletions assembly/broker/configurations/locator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
<api>org.eclipse.kapua.service.device.call.DeviceCallFactory</api>
<api>org.eclipse.kapua.service.device.call.DeviceMessageFactory</api>

<api>org.eclipse.kapua.service.device.management.job.manager.JobDeviceManagementOperationManagerService</api>
<api>org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationService</api>
<api>org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationFactory</api>

<api>org.eclipse.kapua.service.device.management.registry.manager.DeviceManagementRegistryManagerService</api>
<api>org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationRegistryService</api>
<api>org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationFactory</api>
Expand All @@ -72,6 +76,12 @@
<api>org.eclipse.kapua.service.device.registry.event.DeviceEventService</api>
<api>org.eclipse.kapua.service.device.registry.lifecycle.DeviceLifeCycleService</api>

<api>org.eclipse.kapua.service.job.targets.JobTargetService</api>
<api>org.eclipse.kapua.service.job.targets.JobTargetFactory</api>

<api>org.eclipse.kapua.job.engine.JobEngineService</api>
<api>org.eclipse.kapua.job.engine.JobEngineFactory</api>

<api>org.eclipse.kapua.service.tag.TagFactory</api>
<api>org.eclipse.kapua.service.tag.TagService</api>

Expand All @@ -93,6 +103,7 @@
</provided>
<packages>
<package>org.eclipse.kapua.commons</package>
<package>org.eclipse.kapua.job.engine.remote</package>
<package>org.eclipse.kapua.service</package>
<package>org.eclipse.kapua.transport</package>
<package>org.eclipse.kapua.message</package>
Expand Down
10 changes: 10 additions & 0 deletions assembly/broker/descriptors/kapua-broker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
<include>io.netty:netty</include>

<include>javax.inject:javax.inject</include>
<include>javax.batch:javax.batch-api</include>

<include>joda-time:joda-time</include>

Expand Down Expand Up @@ -209,6 +210,7 @@
<include>org.hdrhistogram:HdrHistogram</include>
<include>org.javassist:javassist</include>
<include>org.liquibase:liquibase-core</include>
<include>org.quartz-scheduler:quartz</include>
<include>org.reflections:reflections</include>
<include>org.slf4j:log4j-over-slf4j</include>
<include>org.slf4j:slf4j-api</include>
Expand Down Expand Up @@ -238,6 +240,8 @@
<include>${pom.groupId}:kapua-device-management-command-internal</include>
<include>${pom.groupId}:kapua-device-management-configuration-api</include>
<include>${pom.groupId}:kapua-device-management-configuration-internal</include>
<include>${pom.groupId}:kapua-device-management-job-api</include>
<include>${pom.groupId}:kapua-device-management-job-internal</include>
<include>${pom.groupId}:kapua-device-management-packages-api</include>
<include>${pom.groupId}:kapua-device-management-packages-internal</include>
<include>${pom.groupId}:kapua-device-management-request-api</include>
Expand All @@ -248,8 +252,14 @@
<include>${pom.groupId}:kapua-device-registry-internal</include>
<include>${pom.groupId}:kapua-foreignkeys</include>
<include>${pom.groupId}:kapua-guice</include>
<include>${pom.groupId}:kapua-job-api</include>
<include>${pom.groupId}:kapua-job-internal</include>
<include>${pom.groupId}:kapua-job-engine-api</include>
<include>${pom.groupId}:kapua-job-engine-remote</include>
<include>${pom.groupId}:kapua-message-api</include>
<include>${pom.groupId}:kapua-message-internal</include>
<include>${pom.groupId}:kapua-scheduler-api</include>
<include>${pom.groupId}:kapua-scheduler-quartz</include>
<include>${pom.groupId}:kapua-security-authentication-api</include>
<include>${pom.groupId}:kapua-security-authorization-api</include>
<include>${pom.groupId}:kapua-security-certificate-api</include>
Expand Down
38 changes: 37 additions & 1 deletion assembly/broker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-device-management-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-device-management-job-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-device-management-job-internal</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-device-registry-api</artifactId>
Expand All @@ -94,7 +102,27 @@
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-tag-api</artifactId>
<artifactId>kapua-job-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-job-internal</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-job-engine-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-job-engine-remote</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-scheduler-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-scheduler-quartz</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
Expand All @@ -104,6 +132,10 @@
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-security-certificate-internal</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-tag-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-tag-internal</artifactId>
Expand Down Expand Up @@ -276,6 +308,10 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>javax.batch</groupId>
<artifactId>javax.batch-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
9 changes: 9 additions & 0 deletions broker-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
<artifactId>kapua-device-call-kura</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-device-management-job-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-device-management-registry-api</artifactId>
Expand Down Expand Up @@ -194,6 +199,10 @@
<artifactId>netty-all</artifactId>
</dependency>
<!-- misc -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2017 Eurotech and/or its affiliates and others
* Copyright (c) 2018, 2019 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -8,39 +8,40 @@
*
* Contributors:
* Eurotech - initial API and implementation
* Red Hat Inc
*******************************************************************************/
package org.eclipse.kapua.broker.core.listener;

import com.codahale.metrics.Counter;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import org.apache.camel.Exchange;
import org.apache.camel.spi.UriEndpoint;
import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.broker.core.message.CamelKapuaMessage;
import org.eclipse.kapua.commons.metric.MetricServiceFactory;
import org.eclipse.kapua.commons.metric.MetricsService;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.service.device.management.job.manager.JobDeviceManagementOperationManagerService;
import org.eclipse.kapua.service.device.management.message.notification.KapuaNotifyMessage;
import org.eclipse.kapua.service.device.management.message.notification.KapuaNotifyPayload;
import org.eclipse.kapua.service.device.management.registry.manager.DeviceManagementRegistryManagerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Device management notification listener
* {@link DeviceManagementNotificationMessageProcessor}
*
* @since 1.0
* @since 1.0.0
*/
@UriEndpoint(title = "Device management notification storage message processor", syntax = "bean:deviceManagementNotificationMessageProcessor", scheme = "bean")
public class DeviceManagementNotificationMessageProcessor extends AbstractProcessor<CamelKapuaMessage<?>> {

private static final Logger LOG = LoggerFactory.getLogger(DeviceManagementNotificationMessageProcessor.class);

private static final DeviceManagementRegistryManagerService DEVICE_MANAGEMENT_REGISTRY_MANAGER_SERVICE = KapuaLocator.getInstance().getService(DeviceManagementRegistryManagerService.class);
private static final JobDeviceManagementOperationManagerService JOB_DEVICE_MANAGEMENT_OPERATION_MANAGER_SERVICE = KapuaLocator.getInstance().getService(JobDeviceManagementOperationManagerService.class);

private static final Logger LOG = LoggerFactory.getLogger(DeviceManagementNotificationMessageProcessor.class);
private static final String METRIC_COMPONENT_NAME = "deviceManagementRegistry";


// queues counters
private final Counter metricQueueCommunicationErrorCount;
private final Counter metricQueueConfigurationErrorCount;
Expand All @@ -56,7 +57,7 @@ public DeviceManagementNotificationMessageProcessor() {
}

/**
* Process a device management notification message.
* Process a device management {@link KapuaNotifyMessage}.
*
* @throws KapuaException
*/
Expand All @@ -65,16 +66,27 @@ public void processMessage(CamelKapuaMessage<?> message) throws KapuaException {
LOG.debug("Received notification message from device channel: client id '{}' - {}", message.getMessage().getClientId(), message.getMessage().getChannel());

KapuaNotifyMessage notifyMessage = (KapuaNotifyMessage) message.getMessage();

KapuaNotifyPayload notifyPayload = notifyMessage.getPayload();

DEVICE_MANAGEMENT_REGISTRY_MANAGER_SERVICE.processOperationNotification(
notifyMessage.getScopeId(),
notifyPayload.getOperationId(),
Objects.firstNonNull(notifyMessage.getSentOn(), notifyMessage.getReceivedOn()),
notifyPayload.getResource(),
notifyPayload.getStatus(),
notifyPayload.getProgress());
try {
DEVICE_MANAGEMENT_REGISTRY_MANAGER_SERVICE.processOperationNotification(
notifyMessage.getScopeId(),
notifyPayload.getOperationId(),
MoreObjects.firstNonNull(notifyMessage.getSentOn(), notifyMessage.getReceivedOn()),
notifyPayload.getResource(),
notifyPayload.getStatus(),
notifyPayload.getProgress());

JOB_DEVICE_MANAGEMENT_OPERATION_MANAGER_SERVICE.processJobTargetOnNotification(
notifyMessage.getScopeId(),
notifyPayload.getOperationId(),
MoreObjects.firstNonNull(notifyMessage.getSentOn(), notifyMessage.getReceivedOn()),
notifyPayload.getResource(),
notifyPayload.getStatus());
} catch (Exception e) {
LOG.error("Error while processing Device Management Operation Notification message!", e);
throw e;
}
}

public void processCommunicationErrorMessage(Exchange exchange, CamelKapuaMessage<?> message) throws KapuaException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
*******************************************************************************/
package org.eclipse.kapua.commons.model;

import org.eclipse.kapua.commons.util.PropertiesUtils;
import org.eclipse.kapua.entity.EntityPropertiesReadException;
import org.eclipse.kapua.entity.EntityPropertiesWriteException;
import org.eclipse.kapua.model.KapuaEntity;
import org.eclipse.kapua.model.KapuaUpdatableEntityCreator;
import org.eclipse.kapua.model.id.KapuaId;

import java.io.IOException;
import java.util.Properties;

/**
Expand All @@ -25,12 +29,12 @@
*/
public abstract class AbstractKapuaUpdatableEntityCreator<E extends KapuaEntity> extends AbstractKapuaEntityCreator<E> implements KapuaUpdatableEntityCreator<E> {

protected Properties entityAttributes;
protected String attributes;

/**
* Constructor
* Constructor.
*
* @param scopeId the scope {@link KapuaId}
* @param scopeId The scope {@link KapuaId} to set to in the {@link KapuaUpdatableEntityCreator}
* @since 1.0.0
*/
public AbstractKapuaUpdatableEntityCreator(KapuaId scopeId) {
Expand All @@ -39,14 +43,19 @@ public AbstractKapuaUpdatableEntityCreator(KapuaId scopeId) {

@Override
public Properties getEntityAttributes() {
if (entityAttributes==null) {
entityAttributes = new Properties();
try {
return PropertiesUtils.readPropertiesFromString(attributes);
} catch (IOException e) {
throw new EntityPropertiesReadException(e, "attributes", attributes);
}
return entityAttributes;
}

@Override
public void setEntityAttributes(Properties entityAttributes) {
this.entityAttributes = entityAttributes;
public void setEntityAttributes(Properties attributes) {
try {
this.attributes = PropertiesUtils.writePropertiesToString(attributes);
} catch (IOException e) {
throw new EntityPropertiesWriteException(e, "attributes", attributes);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ public enum GwtKapuaErrorCode {
TRIGGER_NEVER_FIRE,
JOB_STARTING_ERROR,
ADMIN_ROLE_DELETED_ERROR,
PERMISSION_DELETE_NOT_ALLOWED
PERMISSION_DELETE_NOT_ALLOWED,
JOB_STOPPING_ERROR,
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ RETRY_AND_CRON_BOTH_SELECTED=There should only be one scheduling parameter - eit
DOWNLOAD_PACKAGE_EXCEPTION=Error: Another resource is currently downloading. Please wait a few moments so package finishes downloading and then try again.
TRIGGER_NEVER_FIRE=There is problem with Job scheduling. Either Job does not exist, there is a problem with schedule's trigger or an internal scheduler error occurred.
JOB_STARTING_ERROR=Selected job could not be started. There is a problem with its parameters, it has already been started or it has not finished yet. Please check the configuration or try again later.
JOB_STOPPING_ERROR=Selected job could not be stopped. No execution running found.
ADMIN_ROLE_DELETED_ERROR=Operation not allowed on admin role.
PERMISSION_DELETE_NOT_ALLOWED=Operation not allowed on this specific permission.

Expand Down
Loading

0 comments on commit 33d63bb

Please sign in to comment.