Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile warnings in mantis-control-plane-server #417

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

import io.mantisrx.server.master.resourcecluster.ClusterID;
import io.mantisrx.server.master.resourcecluster.TaskExecutorRegistration;
import io.mantisrx.shaded.com.google.common.io.BaseEncoding;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.Instant;
import java.util.Map;
import java.util.TreeMap;
import javax.annotation.Nullable;
import javax.xml.bind.DatatypeConverter;
import lombok.Value;

@Value
Expand Down Expand Up @@ -57,7 +57,7 @@ public String getHash() {
messageDigest.update(key.getBytes(StandardCharsets.UTF_8));
messageDigest.update(value.getBytes(StandardCharsets.UTF_8));
});
return DatatypeConverter.printHexBinary(messageDigest.digest());
return BaseEncoding.base16().encode(messageDigest.digest());
} catch (NoSuchAlgorithmException exception) {
// don't expect this to happen
// let's just throw a runtime exception in this case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public void onInitialize(InitializeAgentsErrorMonitor initializeAgentsErrorMonit
slaveDisabler = hostName -> mantisSchedulerOptional.get().disableVM(hostName,disableDurationMillis);
slaveEnabler = hostName -> mantisSchedulerOptional.get().enableVM(hostName);
getContext().become(initializedBehavior);
getTimers().startPeriodicTimer(CHECK_HOST_TIMER_KEY, new CheckHostHealthMessage(), scala.concurrent.duration.Duration.create(error_check_window_millis, TimeUnit.MILLISECONDS));
getTimers().startTimerAtFixedRate(CHECK_HOST_TIMER_KEY, new CheckHostHealthMessage(),
scala.concurrent.duration.Duration.create(error_check_window_millis, TimeUnit.MILLISECONDS));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import akka.NotUsed;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.http.javadsl.ConnectHttp;
import akka.http.javadsl.Http;
import akka.http.javadsl.ServerBinding;
import akka.http.javadsl.model.HttpEntity;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.HttpResponse;
import akka.stream.ActorMaterializer;
import akka.stream.javadsl.Flow;
import akka.http.javadsl.server.Route;
import akka.stream.Materializer;
import akka.util.ByteString;
import com.netflix.fenzo.AutoScaleAction;
import com.netflix.fenzo.AutoScaleRule;
Expand Down Expand Up @@ -77,7 +75,7 @@

public class AgentClusterRouteTest {
private final static Logger logger = LoggerFactory.getLogger(AgentClusterRouteTest.class);
private final ActorMaterializer materializer = ActorMaterializer.create(system);
private final Materializer materializer = Materializer.createMaterializer(system);
private final Http http = Http.get(system);
private static Thread t;
private static final int serverPort = 8209;
Expand Down Expand Up @@ -119,7 +117,6 @@ public static void setup() throws InterruptedException {
// boot up server using the route as defined below
TestHelpers.setupMasterConfig();
final Http http = Http.get(system);
final ActorMaterializer materializer = ActorMaterializer.create(system);
IMantisPersistenceProvider storageProvider = new FileBasedPersistenceProvider(true);
final LifecycleEventPublisher lifecycleEventPublisher = new LifecycleEventPublisherImpl(new AuditEventSubscriberLoggingImpl(), new StatusEventSubscriberLoggingImpl(), new WorkerEventSubscriberLoggingImpl());

Expand All @@ -140,10 +137,11 @@ public static void setup() throws InterruptedException {
"cluster"),
system);

final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = v0AgentClusterRoute.createRoute(Function.identity()).flow(system, materializer);
final Route route = v0AgentClusterRoute.createRoute(Function.identity());
logger.info("test server starting on port {}", serverPort);
binding = http.bindAndHandle(routeFlow,
ConnectHttp.toHost("localhost", serverPort), materializer);
binding = http
.newServerAt("localhost", serverPort)
.bind(route);
latch.countDown();
} catch (Exception e) {
logger.info("caught exception", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import akka.NotUsed;
import akka.http.javadsl.ConnectHttp;
import akka.http.javadsl.Http;
import akka.http.javadsl.ServerBinding;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.HttpResponse;
import akka.stream.Materializer;
import akka.stream.javadsl.Flow;
import akka.http.javadsl.server.Route;
import com.netflix.mantis.master.scheduler.TestHelpers;
import io.mantisrx.master.api.akka.route.Jackson;
import io.mantisrx.master.jobcluster.job.JobTestHelper;
Expand Down Expand Up @@ -80,12 +77,12 @@ public static void setup() throws Exception {
try {
// boot up server using the route as defined below
final Http http = Http.get(system);
final Materializer materializer = Materializer.createMaterializer(system);

final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = masterDescRoute.createRoute(Function.identity()).flow(system, materializer);
final Route route = masterDescRoute.createRoute(Function.identity());
logger.info("starting test server on port {}", ADMIN_MASTER_PORT);
binding = http.bindAndHandle(routeFlow,
ConnectHttp.toHost("localhost", ADMIN_MASTER_PORT), materializer);
binding = http
.newServerAt("localhost", ADMIN_MASTER_PORT)
.bind(route);
latch.countDown();
} catch (Exception e) {
logger.info("caught exception", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,18 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import akka.NotUsed;
import akka.actor.ActorRef;
import akka.http.javadsl.ConnectHttp;
import akka.http.javadsl.Http;
import akka.http.javadsl.ServerBinding;
import akka.http.javadsl.model.ContentTypes;
import akka.http.javadsl.model.HttpEntities;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.HttpResponse;
import akka.stream.ActorMaterializer;
import akka.stream.javadsl.Flow;
import akka.http.javadsl.server.Route;
import com.netflix.fenzo.AutoScaleAction;
import com.netflix.fenzo.AutoScaleRule;
import com.netflix.fenzo.VirtualMachineLease;
Expand Down Expand Up @@ -100,7 +97,6 @@ public static void setup() throws InterruptedException {
try {
// boot up server using the route as defined below
final Http http = Http.get(system);
final ActorMaterializer materializer = ActorMaterializer.create(system);
IMantisPersistenceProvider storageProvider = new FileBasedPersistenceProvider(true);
final LifecycleEventPublisher lifecycleEventPublisher = new LifecycleEventPublisherImpl(
new AuditEventSubscriberLoggingImpl(),
Expand Down Expand Up @@ -132,12 +128,11 @@ public static void setup() throws InterruptedException {
lifecycleEventPublisher,
"cluster"));

final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = agentClusterV2Route.createRoute(
Function.identity()).flow(system, materializer);
final Route route = agentClusterV2Route.createRoute(Function.identity());
logger.info("test server starting on port {}", serverPort);
binding = http.bindAndHandle(routeFlow,
ConnectHttp.toHost("localhost", serverPort),
materializer);
binding = http
.newServerAt("localhost", serverPort)
.bind(route);;
latch.countDown();
} catch (Exception e) {
logger.info("caught exception", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
Expand Down