Remove this for member variable

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-02-09 11:29:01 +01:00
parent 1bb29338ac
commit ceb23e65e4
33 changed files with 1214 additions and 1241 deletions

View File

@@ -61,41 +61,41 @@ public class DDISimulatedDevice extends AbstractSimulatedDevice {
@Override
public void clean() {
super.clean();
this.removed = true;
removed = true;
}
public int getPollDelaySec() {
return this.pollDelaySec;
return pollDelaySec;
}
/**
* Polls the base URL for the DDI API interface.
*/
public void poll() {
if (!this.removed) {
final String basePollJson = this.controllerResource.get(getTenant(), getId());
if (!removed) {
final String basePollJson = controllerResource.get(getTenant(), getId());
try {
final String href = JsonPath.parse(basePollJson).read("_links.deploymentBase.href");
final long actionId = Long.parseLong(href.substring(href.lastIndexOf("/") + 1, href.indexOf("?")));
if (this.currentActionId == null) {
final String deploymentJson = this.controllerResource.getDeployment(getTenant(), getId(), actionId);
if (currentActionId == null) {
final String deploymentJson = controllerResource.getDeployment(getTenant(), getId(), actionId);
final String swVersion = JsonPath.parse(deploymentJson).read("deployment.chunks[0].version");
this.currentActionId = actionId;
this.deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, (device, actionId1) -> {
currentActionId = actionId;
deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, (device, actionId1) -> {
switch (device.getResponseStatus()) {
case SUCCESSFUL:
DDISimulatedDevice.this.controllerResource.postSuccessFeedback(getTenant(), getId(),
controllerResource.postSuccessFeedback(getTenant(), getId(),
actionId1);
break;
case ERROR:
DDISimulatedDevice.this.controllerResource.postErrorFeedback(getTenant(), getId(),
controllerResource.postErrorFeedback(getTenant(), getId(),
actionId1);
break;
default:
throw new IllegalStateException(
"simulated device has an unknown response status + " + device.getResponseStatus());
}
DDISimulatedDevice.this.currentActionId = null;
currentActionId = null;
});
}
} catch (final PathNotFoundException e) {

View File

@@ -58,13 +58,12 @@ public class DeviceSimulatorUpdater {
*/
public void startUpdate(final String tenant, final String id, final long actionId, final String swVersion,
final UpdaterCallback callback) {
final AbstractSimulatedDevice device = this.repository.get(tenant, id);
final AbstractSimulatedDevice device = repository.get(tenant, id);
device.setProgress(0.0);
device.setSwversion(swVersion);
this.eventbus.post(new InitUpdate(device));
threadPool.schedule(
new DeviceSimulatorUpdateThread(device, this.spSenderService, actionId, this.eventbus, callback), 2000,
TimeUnit.MILLISECONDS);
eventbus.post(new InitUpdate(device));
threadPool.schedule(new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback),
2000, TimeUnit.MILLISECONDS);
}
private static final class DeviceSimulatorUpdateThread implements Runnable {
@@ -87,15 +86,16 @@ public class DeviceSimulatorUpdater {
@Override
public void run() {
final double newProgress = this.device.getProgress() + 0.2;
this.device.setProgress(newProgress);
final double newProgress = device.getProgress() + 0.2;
device.setProgress(newProgress);
if (newProgress < 1.0) {
threadPool.schedule(new DeviceSimulatorUpdateThread(this.device, this.spSenderService, this.actionId,
this.eventbus, this.callback), rndSleep.nextInt(3000), TimeUnit.MILLISECONDS);
threadPool.schedule(
new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback),
rndSleep.nextInt(3000), TimeUnit.MILLISECONDS);
} else {
this.callback.updateFinished(this.device, this.actionId);
callback.updateFinished(device, actionId);
}
this.eventbus.post(new ProgressUpdate(this.device));
eventbus.post(new ProgressUpdate(device));
}
}

View File

@@ -54,7 +54,7 @@ public class NextPollTimeController {
private class NextPollUpdaterRunnable implements Runnable {
@Override
public void run() {
final List<AbstractSimulatedDevice> devices = NextPollTimeController.this.repository.getAll().stream()
final List<AbstractSimulatedDevice> devices = repository.getAll().stream()
.filter(device -> device instanceof DDISimulatedDevice).collect(Collectors.toList());
devices.forEach(device -> {
@@ -71,7 +71,7 @@ public class NextPollTimeController {
}
device.setNextPollCounterSec(nextCounter);
});
NextPollTimeController.this.eventBus.post(new NextPollCounterUpdate(devices));
eventBus.post(new NextPollCounterUpdate(devices));
}
}
}