Removed percentage from the event. Moved event into the repo API.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
kaizimmerm
2016-07-08 13:00:47 +02:00
parent 8fb2bd4322
commit 9a4903526a
15 changed files with 78 additions and 80 deletions

View File

@@ -14,8 +14,8 @@ import java.util.Map;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.eventbus.event.DownloadProgressEvent;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.eventbus.event.DownloadProgressEvent;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.ToManyAttributeEntriesException;
@@ -58,21 +58,20 @@ public interface ControllerManagement {
Action addCancelActionStatus(@NotNull ActionStatus actionStatus);
/**
* Sends the download progress in percentage and notifies the
* {@link EventBus} with a {@link DownloadProgressEvent}.
* Sends the download progress and notifies the {@link EventBus} with a
* {@link DownloadProgressEvent}.
*
* @param statusId
* the ID of the {@link ActionStatus}
* @param progressPercent
* the progress in percentage which must be between 0-100
* @param requestedBytes
* requested bytes of the request
* @param shippedBytesSinceLast
* since the last report
* @param shippedBytesOverall
* for the {@link ActionStatus}
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
void downloadProgressPercent(long statusId, int progressPercent, long shippedBytesSinceLast,
long shippedBytesOverall);
void downloadProgress(Long statusId, Long requestedBytes, Long shippedBytesSinceLast, Long shippedBytesOverall);
/**
* Simple addition of a new {@link ActionStatus} entry to the {@link Action}

View File

@@ -16,10 +16,11 @@ import org.springframework.security.access.prepost.PreAuthorize;
* Management service for statistics of a single tenant.
*
*/
@FunctionalInterface
public interface TenantStatsManagement {
/**
* Service for stats of a single tenant.
* Service for stats of the current tenant.
*
* @return collected statistics
*/

View File

@@ -0,0 +1,67 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.eventbus.event;
import org.eclipse.hawkbit.eventbus.event.AbstractDistributedEvent;
/**
* Event that contains an updated download progress for a given ActionStatus
* that was written for a download request.
*
*/
public class DownloadProgressEvent extends AbstractDistributedEvent {
private static final long serialVersionUID = 1L;
private final Long statusId;
private final long requestedBytes;
private final long shippedBytesSinceLast;
private final long shippedBytesOverall;
/**
* Constructor.
*
* @param tenant
* the tenant for this event
* @param statusId
* of ActionStatus that was written for the download request
* @param requestedBytes
* bytes requested
* @param shippedBytesSinceLast
* bytes since last event
* @param shippedBytesOverall
* on the download request
*/
public DownloadProgressEvent(final String tenant, final Long statusId, final Long requestedBytes,
final Long shippedBytesSinceLast, final Long shippedBytesOverall) {
// the revision of the DownloadProgressEvent is just equal the
// shippedBytesOverall as this is a growing number.
super(shippedBytesOverall, tenant);
this.statusId = statusId;
this.requestedBytes = requestedBytes;
this.shippedBytesSinceLast = shippedBytesSinceLast;
this.shippedBytesOverall = shippedBytesOverall;
}
public Long getStatusId() {
return statusId;
}
public long getRequestedBytes() {
return requestedBytes;
}
public long getShippedBytesSinceLast() {
return shippedBytesSinceLast;
}
public long getShippedBytesOverall() {
return shippedBytesOverall;
}
}

View File

@@ -39,12 +39,6 @@ public interface Action extends TenantAwareBaseEntity {
return Status.CANCELING.equals(getStatus()) || Status.CANCELED.equals(getStatus());
}
/**
* @return current {@link Status#DOWNLOAD} progress if known by the update
* server.
*/
int getDownloadProgressPercent();
/**
* @return current {@link Status} of the {@link Action}.
*/

View File

@@ -43,6 +43,12 @@ public interface ActionStatus extends TenantAwareBaseEntity {
*/
void addMessage(String message);
/**
* @return current {@link Status#DOWNLOAD} progress if known by the update
* server.
*/
int getDownloadProgressPercent();
/**
* @return list of message entries that can be added to the
* {@link ActionStatus}.