Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
command: mvn verify sonar:sonar

executors:
j19:
jdk:
docker:
- image: 'cimg/openjdk:21.0.6'

Expand All @@ -22,6 +22,6 @@ workflows:
maven_test:
jobs:
- maven/test:
executor: j19
executor: jdk
- build:
context: SonarCloud
23 changes: 10 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,16 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<release>${java.version}</release>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<release>${java.version}</release>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
7 changes: 4 additions & 3 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: skaffold/v2beta29
apiVersion: skaffold/v4beta5
kind: Config
metadata:
name: sample-java-concurrency
Expand All @@ -21,6 +21,7 @@ build:
local:
push: true
deploy:
kubectl:
manifests:
kubectl: {}
manifests:
rawYaml:
- k8s/deployment.yaml
1 change: 0 additions & 1 deletion src/main/java/pl/piomin/model/CustomTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;

public record CustomTask(long startTime, String msg, long id) implements Delayed {

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/pl/piomin/server/SimpleCPUConsumeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
import java.math.BigInteger;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;

public class SimpleCPUConsumeHandler implements HttpHandler {

// Logger LOG = Logger.getLogger("handler");
Logger LOG = Logger.getLogger("handler");
AtomicLong i = new AtomicLong();

@Override
public void handle(HttpExchange exchange) throws IOException {
new BigInteger(200, 3, new Random());
String response = "Hello_" + i.incrementAndGet();
// LOG.log(Level.INFO, "(thread->{0}) {1}", new Object[] {Thread.currentThread(), response});
LOG.log(Level.INFO, "(thread->{0}) {1}", new Object[] {Thread.currentThread(), response});
exchange.sendResponseHeaders(200, response.length());
OutputStream os = exchange.getResponseBody();
os.write(response.getBytes());
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/pl/piomin/server/SimpleDelayedHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public void handle(HttpExchange t) throws IOException {
if (withLock) {
response = workers.get((int) (id.incrementAndGet() % workersCount)).doJob();
} else {
// try {
// Thread.sleep(200);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
new BigInteger(500, 10, new Random());
response = "Ping_" + id.incrementAndGet();
}
Expand Down