Skip to content

Commit

Permalink
alpha3
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabattaglia committed Aug 11, 2021
1 parent 1efccd9 commit 8ab9178
Show file tree
Hide file tree
Showing 40 changed files with 154 additions and 42 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>2.1.0.Final</quarkus.platform.version>
<quarkus.platform.version>2.1.1.Final</quarkus.platform.version>
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
</properties>
<dependencyManagement>
Expand All @@ -27,7 +27,7 @@
<!-- <version>${quarkus.platform.version}</version> -->
<groupId>io.quarkus</groupId>
<artifactId>quarkus-universe-bom</artifactId>
<version>2.1.0.Final</version>
<version>2.1.1.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import io.quarkus.runtime.annotations.RegisterForReflection;

/**
* @author andreabattaglia
*
*/
@RegisterForReflection
public class MachineryDataDTO {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import io.qiot.manufacturing.commons.domain.production.ProductionChainStageEnum;
import io.quarkus.runtime.annotations.RegisterForReflection;

/**
* @author andreabattaglia
*
*/
@RegisterForReflection
public class ProductionCountersDTO {
public UUID productLineId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import io.qiot.manufacturing.commons.domain.production.ItemDTO;
import io.quarkus.runtime.annotations.RegisterForReflection;

/**
* @author andreabattaglia
*
*/
@RegisterForReflection
public class StageCompletedEvent {
public ItemDTO item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import io.qiot.manufacturing.commons.domain.productionvalidation.AbstractProductionChainEventDTO;
import io.quarkus.runtime.annotations.RegisterForReflection;

/**
* @author andreabattaglia
*
*/
@RegisterForReflection
public class ValidationFailedEvent extends AbstractProductionChainEventDTO {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import io.qiot.manufacturing.commons.domain.productionvalidation.AbstractProductionChainEventDTO;
import io.quarkus.runtime.annotations.RegisterForReflection;

/**
* @author andreabattaglia
*
*/
@RegisterForReflection
public class ValidationSuccessfullEvent extends AbstractProductionChainEventDTO {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import io.qiot.manufacturing.commons.domain.productline.ProductLineDTO;
import io.quarkus.runtime.annotations.RegisterForReflection;

/**
* @author andreabattaglia
*
*/
@RegisterForReflection
public class ProductLineChangedEventDTO {
public ProductLineDTO productLine;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.qiot.manufacturing.edge.machinery.service.core;

/**
* @author andreabattaglia
*
*/
public interface CoreService {

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class CoreServiceImpl implements CoreService {
Event<BootstrapCompletedEventDTO> event;

void onStart(@Observes StartupEvent ev) throws DataValidationException {
LOGGER.info("The application is starting...{}");
LOGGER.debug("The application is starting...{}");
// stationData =
scheduler.pause();
machineryService.checkRegistration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import io.qiot.manufacturing.edge.machinery.domain.MachineryDataDTO;
import io.qiot.manufacturing.edge.machinery.util.exception.DataValidationException;

/**
* @author andreabattaglia
*
*/
public interface MachineryService {

MachineryDataDTO checkRegistration() throws DataValidationException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class MachineryServiceImpl implements MachineryService {
public MachineryDataDTO checkRegistration() throws DataValidationException {
Path dataFilePath = Paths.get(dataFilePathString);
if (Files.exists(dataFilePath)) {
LOGGER.info(
LOGGER.debug(
"Device is already registered. Loading data from persistent volume...");
try {
String datafileContent = Files.readString(dataFilePath);
Expand All @@ -67,9 +67,9 @@ public MachineryDataDTO checkRegistration() throws DataValidationException {
e);
throw new DataValidationException(e);
}
LOGGER.info("Data loaded successfully: {}", machineryData);
LOGGER.debug("Data loaded successfully: {}", machineryData);
} else {
LOGGER.info(
LOGGER.debug(
"Device is not registered. Stepping through the registration process...");

machineryData = new MachineryDataDTO();
Expand All @@ -87,15 +87,15 @@ public MachineryDataDTO checkRegistration() throws DataValidationException {
// ksPassword);
// }

LOGGER.info("Received machinery ID: {}", machineryId);
LOGGER.debug("Received machinery ID: {}", machineryId);
machineryData.id = machineryId;
Files.createFile(dataFilePath);

String machineryDataString = MAPPER
.writeValueAsString(machineryData);
Files.writeString(dataFilePath, machineryDataString);

LOGGER.info("Data Created successfully: {}", machineryData);
LOGGER.debug("Data Created successfully: {}", machineryData);
} catch (Exception e) {
LOGGER.error(
"An error occurred registering the measurement machinery.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import io.qiot.manufacturing.commons.domain.production.ItemDTO;
import io.qiot.manufacturing.commons.domain.production.ProductionChainStageEnum;

/**
* @author andreabattaglia
*
*/
public interface ConveyorBeltService {
void createNewItem(UUID productLineId, int itemId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import io.qiot.manufacturing.commons.domain.production.ItemDTO;
import io.qiot.manufacturing.commons.domain.production.ProductionChainStageEnum;

/**
* @author andreabattaglia
*
*/
@ApplicationScoped
public class ConveyorBeltServiceImpl implements ConveyorBeltService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

import io.qiot.manufacturing.commons.domain.production.ProductionChainStageEnum;

/**
* @author andreabattaglia
*
*/
public interface CountersService {
int recordNewItem(UUID productLineId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import io.qiot.manufacturing.commons.domain.production.ProductionChainStageEnum;
import io.qiot.manufacturing.edge.machinery.domain.ProductionCountersDTO;

/**
* @author andreabattaglia
*
*/
@ApplicationScoped
public class CountersServiceImpl implements CountersService {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.qiot.manufacturing.edge.machinery.service.production;

/**
* @author andreabattaglia
*
*/
public interface ProductionChainService {

// void produce();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void produce() {
}

void onStageCompleted(@Observes StageCompletedEvent event) {
LOGGER.info("Recording changes and notifying...");
LOGGER.debug("Recording changes and notifying...");
ItemDTO item = event.item;
countersService.recordStageEnd(item.id, item.productLineId, item.stage);
conveyorBeltService.moveToWaitingQueue(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import io.qiot.manufacturing.edge.machinery.service.production.ConveyorBeltService;
import io.qiot.manufacturing.edge.machinery.service.productline.ProductLineService;

/**
* @author andreabattaglia
*
*/
public abstract class AbstractChainService implements ChainService {

@Inject
Expand All @@ -40,28 +44,28 @@ void init() {
public void doSimulate() {
ItemDTO item = poll(getStage());
if (Objects.isNull(item)) {
getLogger().info("No items available in conveyor belt for stage {}",
getLogger().debug("No items available in conveyor belt for stage {}",
getStage());
return;
}
getLogger().info(
getLogger().debug(
"{} process started for Item #{} and Product Line #{}.",
getStage(), item.id, item.productLineId);
checkProductLineId(item.productLineId);
// if (Objects.isNull(item.productLineId)) {
// getLogger().info("No Product Line available.");
// getLogger().debug("No Product Line available.");
// return;
// }
item.stage = getStage();
try {
long sleepTime = sleepRandomNumberGenerator.nextLong();
getLogger().info("Sleeping for {} millis.", sleepTime);
getLogger().debug("Sleeping for {} millis.", sleepTime);
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
generate(item);
getLogger().info(
getLogger().debug(
"{} process completed for Item #{} and Product Line #{}.",
getStage(), item.id, item.productLineId);
notify(item);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.qiot.manufacturing.edge.machinery.service.production.chain;

/**
* @author andreabattaglia
*
*/
public interface ChainService {

void simulate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import io.qiot.manufacturing.commons.domain.event.BootstrapCompletedEventDTO;
import io.qiot.manufacturing.commons.domain.productionvalidation.ValidationResponseDTO;
import io.qiot.manufacturing.commons.domain.productline.ProductLineDTO;
import io.qiot.manufacturing.commons.util.producer.ProductLineReplyToQueueNameProducer;
import io.qiot.manufacturing.commons.util.producer.ValidationReplyToQueueNameProducer;
import io.qiot.manufacturing.edge.machinery.domain.event.chain.ValidationFailedEvent;
import io.qiot.manufacturing.edge.machinery.domain.event.chain.ValidationSuccessfullEvent;
import io.qiot.manufacturing.edge.machinery.domain.event.productline.ProductLineChangedEventDTO;
import io.qiot.manufacturing.edge.machinery.service.machinery.MachineryService;

/**
* @author andreabattaglia
*
*/
@ApplicationScoped
public class LatestProductLineMessageConsumer implements Runnable {

Expand Down Expand Up @@ -65,7 +65,7 @@ public class LatestProductLineMessageConsumer implements Runnable {
.newSingleThreadExecutor();

void init(@Observes BootstrapCompletedEventDTO event) {
LOGGER.info("Bootstrapping new product line durable subscriber...");
LOGGER.debug("Bootstrapping new product line durable subscriber...");
initSubscriber();

scheduler.submit(this);
Expand Down Expand Up @@ -99,7 +99,7 @@ public void run() {
String messagePayload = message.getBody(String.class);
ProductLineDTO productLine = MAPPER.readValue(messagePayload,
ProductLineDTO.class);
LOGGER.info("Received latest PRODUCTLINE available from the Factory Controller: \n {}", productLine);
LOGGER.debug("Received latest PRODUCTLINE available from the Factory Controller: \n {}", productLine);
ProductLineChangedEventDTO eventDTO = new ProductLineChangedEventDTO();
eventDTO.productLine = productLine;
prodictLineChangedEvent.fire(eventDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package io.qiot.manufacturing.edge.machinery.service.productline;

import java.util.Objects;
import java.util.UUID;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
Expand Down Expand Up @@ -47,11 +46,11 @@ public class LatestProductLineRequestMessageProducer {

@PostConstruct
void init() {
LOGGER.info(
LOGGER.debug(
"Bootstrapping latest product line request event producer...");
doInit();

LOGGER.info("Bootstrap completed");
LOGGER.debug("Bootstrap completed");

}

Expand All @@ -66,7 +65,7 @@ private void doInit() {
}

void requestLatestProductLine(String machineryId) {
LOGGER.info(
LOGGER.debug(
"Sending out a request for the latest product line available");
try {
String messagePayload = machineryId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Event;
Expand All @@ -14,9 +13,7 @@
import javax.jms.JMSConsumer;
import javax.jms.JMSContext;
import javax.jms.JMSException;
import javax.jms.JMSProducer;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.Topic;

Expand All @@ -27,14 +24,14 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import io.qiot.manufacturing.commons.domain.event.BootstrapCompletedEventDTO;
import io.qiot.manufacturing.commons.domain.productionvalidation.ValidationResponseDTO;
import io.qiot.manufacturing.commons.domain.productline.ProductLineDTO;
import io.qiot.manufacturing.commons.util.producer.ValidationReplyToQueueNameProducer;
import io.qiot.manufacturing.edge.machinery.domain.event.chain.ValidationFailedEvent;
import io.qiot.manufacturing.edge.machinery.domain.event.chain.ValidationSuccessfullEvent;
import io.qiot.manufacturing.edge.machinery.domain.event.productline.ProductLineChangedEventDTO;
import io.qiot.manufacturing.edge.machinery.service.machinery.MachineryService;

/**
* @author andreabattaglia
*
*/
@ApplicationScoped
public class NewProductLineMessageConsumer implements Runnable {

Expand Down Expand Up @@ -66,7 +63,7 @@ public class NewProductLineMessageConsumer implements Runnable {
.newSingleThreadExecutor();

void init(@Observes BootstrapCompletedEventDTO event) {
LOGGER.info("Bootstrapping new product line durable subscriber...");
LOGGER.debug("Bootstrapping new product line durable subscriber...");
initSubscriber();

scheduler.submit(this);
Expand Down Expand Up @@ -100,7 +97,7 @@ public void run() {
String messagePayload = message.getBody(String.class);
ProductLineDTO productLine = MAPPER.readValue(messagePayload,
ProductLineDTO.class);
LOGGER.info(
LOGGER.debug(
"Received new PRODUCTLINE from the Factory Controller: \n {}",
productLine);
ProductLineChangedEventDTO eventDTO = new ProductLineChangedEventDTO();
Expand Down
Loading

0 comments on commit 8ab9178

Please sign in to comment.