📍Use lombok, reformat, and optimize the code (#1560)

* Use lombok, reformat, and optimize the code

* Fix merge conflicts and some sonar issues

Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
va1m
2021-03-13 13:19:21 +01:00
committed by GitHub
parent 0e26a6adb5
commit 5cf2fe009b
681 changed files with 2472 additions and 4966 deletions

View File

@ -26,8 +26,7 @@ package com.iluwatar.queue.load.leveling;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* Many solutions in the cloud involve running tasks that invoke services. In this environment, if a
@ -58,10 +57,9 @@ import org.slf4j.LoggerFactory;
* MessageQueue. The service executor class {@link ServiceExecutor} will pick up one task at a time
* from the Queue and execute them.
*/
@Slf4j
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
//Executor shut down time limit.
private static final int SHUTDOWN_TIME = 15;

View File

@ -23,22 +23,17 @@
package com.iluwatar.queue.load.leveling;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* Message class with only one parameter.
*/
@Getter
@RequiredArgsConstructor
public class Message {
private final String msg;
// Parameter constructor.
public Message(String msg) {
this.msg = msg;
}
// Get Method for attribute msg.
public String getMsg() {
return msg;
}
@Override
public String toString() {
return msg;

View File

@ -25,17 +25,15 @@ package com.iluwatar.queue.load.leveling;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* MessageQueue class. In this class we will create a Blocking Queue and submit/retrieve all the
* messages from it.
*/
@Slf4j
public class MessageQueue {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
private final BlockingQueue<Message> blkQueue;
// Default constructor when called creates Blocking Queue object.

View File

@ -23,17 +23,15 @@
package com.iluwatar.queue.load.leveling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* ServiceExecuotr class. This class will pick up Messages one by one from the Blocking Queue and
* process them.
*/
@Slf4j
public class ServiceExecutor implements Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
private final MessageQueue msgQueue;
public ServiceExecutor(MessageQueue msgQueue) {

View File

@ -23,18 +23,15 @@
package com.iluwatar.queue.load.leveling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* TaskGenerator class. Each TaskGenerator thread will be a Worker which submit's messages to the
* queue. We need to mention the message count for each of the TaskGenerator threads.
*/
@Slf4j
public class TaskGenerator implements Task, Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
// MessageQueue reference using which we will submit our messages.
private final MessageQueue msgQueue;

View File

@ -30,10 +30,10 @@ import org.junit.jupiter.api.Test;
/**
* Test case for submitting and retrieving messages from Blocking Queue.
*/
public class MessageQueueTest {
class MessageQueueTest {
@Test
public void messageQueueTest() {
void messageQueueTest() {
var msgQueue = new MessageQueue();

View File

@ -30,10 +30,10 @@ import org.junit.jupiter.api.Test;
/**
* Test case for creating and checking the Message.
*/
public class MessageTest {
class MessageTest {
@Test
public void messageTest() {
void messageTest() {
// Parameterized constructor test.
var testMsg = "Message Test";