Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 14 additions & 0 deletions cdap-api-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,18 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
9 changes: 9 additions & 0 deletions cdap-api-spark3_2.12/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
Expand Down
11 changes: 11 additions & 0 deletions cdap-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,16 @@
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
9 changes: 9 additions & 0 deletions cdap-app-fabric-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ the License.

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<!-- Shouldn't deploy test module -->
<plugin>
<groupId>org.sonatype.central</groupId>
Expand Down
10 changes: 9 additions & 1 deletion cdap-app-fabric/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,18 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>test-jar</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ protected void startUp() throws Exception {
// Starts common services
runner = previewInjector.getInstance(PreviewRunner.class);
if (runner instanceof Service) {
((Service) runner).startAndWait();
((Service) runner).startAsync().awaitRunning();
}

// Create and start the preview poller services.
for (int i = 0; i < maxConcurrentPreviews; i++) {
createPreviewRunnerService().startAndWait();
createPreviewRunnerService().startAsync().awaitRunning();
}
}

Expand All @@ -144,7 +144,7 @@ protected void shutDown() throws Exception {

private void stopQuietly(Service service) {
try {
service.stopAndWait();
service.stopAsync().awaitTerminated();
} catch (Exception e) {
LOG.warn("Error stopping the preview runner.", e);
}
Expand All @@ -163,8 +163,8 @@ public void stop(ApplicationId preview) throws Exception {
}

PreviewRunnerService newRunnerService = createPreviewRunnerService();
runnerService.stopAndWait();
newRunnerService.startAndWait();
runnerService.stopAsync().awaitTerminated();
newRunnerService.startAsync().awaitRunning();
}

@Override
Expand Down Expand Up @@ -237,14 +237,14 @@ public InetAddress providesHostname(CConfiguration cConf) {
private PreviewRunnerService createPreviewRunnerService() {
PreviewRunnerService previewRunnerService = previewRunnerServiceFactory.create(runner);

previewRunnerService.addListener(new ServiceListenerAdapter() {
previewRunnerService.addListener(new Service.Listener() {

@Override
public void terminated(State from) {
public void terminated(Service.State from) {
previewRunnerServices.remove(previewRunnerService);
if (previewRunnerServices.isEmpty()) {
try {
stop();
stopAsync();
} catch (Exception e) {
// should not happen
LOG.error("Failed to shutdown the preview runner manager service.", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected void startUp() throws Exception {
Constants.Logging.COMPONENT_NAME,
Constants.Service.PREVIEW_HTTP));
if (previewManager instanceof Service) {
((Service) previewManager).startAndWait();
((Service) previewManager).startAsync().awaitRunning();
}

httpService.start();
Expand All @@ -117,7 +117,7 @@ protected void shutDown() throws Exception {
try {
cancelHttpService.cancel();
if (previewManager instanceof Service) {
((Service) previewManager).stopAndWait();
((Service) previewManager).stopAsync().awaitTerminated();
}
} finally {
httpService.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import io.cdap.cdap.proto.id.ProgramId;
import io.cdap.cdap.proto.id.ProgramRunId;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
Expand Down Expand Up @@ -472,7 +473,11 @@ private ProgramController createController(ProgramId programId, RunId runId,
*/
private void cleanupRuntimeInfo(@Nullable RuntimeInfo info) {
if (info instanceof Closeable) {
Closeables.closeQuietly((Closeable) info);
try {
((Closeable) info).close();
} catch (IOException e) {
// Ignore
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void onSuccess(ProgramController result) {
public void onFailure(Throwable t) {
resultFuture.setException(t);
}
});
}, com.google.common.util.concurrent.MoreExecutors.directExecutor());
});
return resultFuture;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void initialize(EventHandlerContext context) {

if (clusterMode == ClusterMode.ON_PREMISE) {
zkClientService = injector.getInstance(ZKClientService.class);
zkClientService.startAndWait();
zkClientService.startAsync().awaitRunning();
}

LoggingContextAccessor.setLoggingContext(
Expand Down Expand Up @@ -210,9 +210,15 @@ public void aborted() {

@Override
public void destroy() {
Closeables.closeQuietly(logAppenderInitializer);
try {
if (logAppenderInitializer != null) {
logAppenderInitializer.close();
}
} catch (Exception e) {
// Ignore
}
if (zkClientService != null) {
zkClientService.stop();
zkClientService.stopAsync();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package io.cdap.cdap.gateway.handlers;

import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -326,15 +326,15 @@ private void ensureSecurityEnabled() throws FeatureDisabledException {
private void createLogEntry(HttpRequest httpRequest, HttpResponseStatus responseStatus)
throws UnknownHostException {
InetAddress clientAddr = InetAddress.getByName(
Objects.firstNonNull(SecurityRequestContext.getUserIp(), "0.0.0.0"));
MoreObjects.firstNonNull(SecurityRequestContext.getUserIp(), "0.0.0.0"));
AuditLogEntry logEntry = new AuditLogEntry(httpRequest, clientAddr.getHostAddress());
logEntry.setUserName(authenticationContext.getPrincipal().getName());
logEntry.setResponse(responseStatus.code(), 0L);
AUDIT_LOG.trace(logEntry.toString());
}

private Set<? extends Permission> getRequestPermissions(AuthorizationRequest request) {
Set<? extends Permission> permissions = Objects.firstNonNull(request.getPermissions(),
Set<? extends Permission> permissions = MoreObjects.firstNonNull(request.getPermissions(),
Collections.emptySet());
if (request.getActions() != null) {
permissions = Stream.concat(permissions.stream(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package io.cdap.cdap.gateway.handlers;

import com.google.common.base.Preconditions;
import com.google.common.collect.DiscreteDomains;
import com.google.common.collect.DiscreteDomain;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Ranges;
import com.google.common.collect.Range;
import com.google.common.util.concurrent.AbstractIdleService;
import com.google.gson.Gson;
import com.google.inject.Inject;
Expand Down Expand Up @@ -120,8 +120,8 @@ public synchronized void setRestartAllInstancesRequest(String serviceName, long
RestartStatus status = isSuccess ? RestartStatus.SUCCESS : RestartStatus.FAILURE;
Integer serviceInstance = getServiceInstance(serviceName);
int instanceCount = (serviceInstance == null) ? 0 : serviceInstance;
Set<Integer> instancesToRestart = Ranges.closedOpen(0, instanceCount)
.asSet(DiscreteDomains.integers());
Set<Integer> instancesToRestart = com.google.common.collect.ContiguousSet.create(
Range.closedOpen(0, instanceCount), DiscreteDomain.integers());

RestartServiceInstancesStatus restartStatus =
new RestartServiceInstancesStatus(serviceName, startTimeMs, endTimeMs, status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
Expand Down Expand Up @@ -592,13 +592,13 @@ private void doAddSchedule(FullHttpRequest request, HttpResponder responder, Str
// Schedules are versionless
lifecycleService.ensureLatestProgramExists(programId.getProgramReference());

String description = Objects.firstNonNull(scheduleFromRequest.getDescription(), "");
Map<String, String> properties = Objects.firstNonNull(scheduleFromRequest.getProperties(),
String description = MoreObjects.firstNonNull(scheduleFromRequest.getDescription(), "");
Map<String, String> properties = MoreObjects.firstNonNull(scheduleFromRequest.getProperties(),
Collections.emptyMap());
List<? extends Constraint> constraints = Objects.firstNonNull(
List<? extends Constraint> constraints = MoreObjects.firstNonNull(
scheduleFromRequest.getConstraints(), NO_CONSTRAINTS);
long timeoutMillis =
Objects.firstNonNull(scheduleFromRequest.getTimeoutMillis(),
MoreObjects.firstNonNull(scheduleFromRequest.getTimeoutMillis(),
Schedulers.JOB_QUEUE_TIMEOUT_MILLIS);
ProgramSchedule schedule = new ProgramSchedule(scheduleName, description, programId, properties,
scheduleFromRequest.getTrigger(), constraints, timeoutMillis);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,14 @@ public ProgramController dispatchProgram(ProgramRunDispatcherContext dispatcherC
if (artifactsComputeHash && (artifactsComputeHashSnapshot
|| !artifactDescriptor.getArtifactId().getVersion().isSnapshot())) {
Hasher hasher = Hashing.sha256().newHasher();
hasher.putString(artifactDescriptor.getNamespace());
hasher.putString(artifactDescriptor.getArtifactId().getName());
hasher.putString(artifactDescriptor.getArtifactId().getScope().name());
hasher.putString(artifactDescriptor.getArtifactId().getVersion().getVersion());
hasher.putString(artifactDescriptor.getNamespace(),
java.nio.charset.StandardCharsets.UTF_8);
hasher.putString(artifactDescriptor.getArtifactId().getName(),
java.nio.charset.StandardCharsets.UTF_8);
hasher.putString(artifactDescriptor.getArtifactId().getScope().name(),
java.nio.charset.StandardCharsets.UTF_8);
hasher.putString(artifactDescriptor.getArtifactId().getVersion().getVersion(),
java.nio.charset.StandardCharsets.UTF_8);
Map<String, String> arguments = new HashMap<>(options.getArguments().asMap());
arguments.put(ProgramOptionConstants.PROGRAM_JAR_HASH, getArtifactHash(hasher));

Expand Down Expand Up @@ -493,7 +497,11 @@ private Runnable createCleanupTask(final Object... resources) {
file.delete();
}
} else if (resource instanceof Closeable) {
Closeables.closeQuietly((Closeable) resource);
try {
((Closeable) resource).close();
} catch (IOException e) {
// Ignore
}
} else if (resource instanceof Runnable) {
((Runnable) resource).run();
}
Expand Down Expand Up @@ -558,9 +566,9 @@ private ProgramOptions updateProgramOptions(ArtifactId artifactId, ProgramId pro
}

private static void hashArtifactId(Hasher hasher, ArtifactId artifactId) {
hasher.putString(artifactId.getParent().toString());
hasher.putString(artifactId.getArtifact());
hasher.putString(artifactId.getVersion());
hasher.putString(artifactId.getParent().toString(), java.nio.charset.StandardCharsets.UTF_8);
hasher.putString(artifactId.getArtifact(), java.nio.charset.StandardCharsets.UTF_8);
hasher.putString(artifactId.getVersion(), java.nio.charset.StandardCharsets.UTF_8);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public class DefaultPreviewManager extends AbstractIdleService implements Previe
private final PreviewDataCleanupService previewDataCleanupService;
private final MetricsCollectionService metricsCollectionService;
private final AeadCipher userEncryptionAeadCipher;
private boolean metricsCollectionServiceStartedByMe = false;
private Injector previewInjector;
private PreviewDataSubscriberService dataSubscriberService;
private PreviewTMSLogSubscriber logSubscriberService;
Expand Down Expand Up @@ -191,18 +192,21 @@ public class DefaultPreviewManager extends AbstractIdleService implements Previe
protected void startUp() throws Exception {
previewInjector = createPreviewInjector();
StoreDefinition.createAllTables(previewInjector.getInstance(StructuredTableAdmin.class));
metricsCollectionService.start();
if (metricsCollectionService.state() == Service.State.NEW) {
metricsCollectionService.startAsync();
metricsCollectionServiceStartedByMe = true;
}
logAppender = previewInjector.getInstance(LogAppender.class);
logAppender.start();
LoggingContextAccessor.setLoggingContext(
new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(),
Constants.Logging.COMPONENT_NAME,
Constants.Service.PREVIEW_HTTP));
logSubscriberService = previewInjector.getInstance(PreviewTMSLogSubscriber.class);
logSubscriberService.startAndWait();
logSubscriberService.startAsync().awaitRunning();
dataSubscriberService = previewInjector.getInstance(PreviewDataSubscriberService.class);
dataSubscriberService.startAndWait();
previewDataCleanupService.startAndWait();
dataSubscriberService.startAsync().awaitRunning();
previewDataCleanupService.startAsync().awaitRunning();
}

@Override
Expand All @@ -211,7 +215,9 @@ protected void shutDown() throws Exception {
stopQuietly(dataSubscriberService);
stopQuietly(logSubscriberService);
logAppender.stop();
stopQuietly(metricsCollectionService);
if (metricsCollectionServiceStartedByMe) {
stopQuietly(metricsCollectionService);
}
previewLevelDBTableService.close();
}

Expand Down Expand Up @@ -449,7 +455,7 @@ private Principal encryptCredential() {

private void stopQuietly(Service service) {
try {
service.stopAndWait();
service.stopAsync().awaitTerminated();
} catch (Exception e) {
LOG.warn("Exception when stopping service {}", service, e);
}
Expand Down
Loading
Loading