Skip to content

Commit

Permalink
Logging: Fix deprecation warnings (#5405)
Browse files Browse the repository at this point in the history
* deprecated warnings removed

* review changes
  • Loading branch information
abhinav-qlogic authored and chingor13 committed Jun 6, 2019
1 parent c8a6062 commit af8ee56
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.Uninterruptibles;
import com.google.logging.v2.CreateLogMetricRequest;
import com.google.logging.v2.CreateSinkRequest;
Expand Down Expand Up @@ -142,7 +143,8 @@ private static <I, O> ApiFuture<O> transform(
public O apply(I i) {
return function.apply(i);
}
});
},
MoreExecutors.directExecutor());
}

private abstract static class BasePageFetcher<T> implements AsyncPageImpl.NextPageFetcher<T> {
Expand Down Expand Up @@ -615,7 +617,8 @@ public void onFailure(Throwable t) {
removeFromPending();
}
}
});
},
MoreExecutors.directExecutor());
break;
}
}
Expand All @@ -629,7 +632,7 @@ private ApiFuture<Void> writeAsync(Iterable<LogEntry> logEntries, WriteOption...
static ListLogEntriesRequest listLogEntriesRequest(
String projectId, Map<Option.OptionType, ?> options) {
ListLogEntriesRequest.Builder builder = ListLogEntriesRequest.newBuilder();
builder.addProjectIds(projectId);
builder.addResourceNames("projects/" + projectId);
Integer pageSize = PAGE_SIZE.get(options);
if (pageSize != null) {
builder.setPageSize(pageSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.google.cloud.logging.v2.LoggingSettings;
import com.google.cloud.logging.v2.MetricsClient;
import com.google.cloud.logging.v2.MetricsSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.logging.v2.CreateLogMetricRequest;
import com.google.logging.v2.CreateSinkRequest;
import com.google.logging.v2.DeleteLogMetricRequest;
Expand Down Expand Up @@ -96,7 +97,7 @@ public GrpcLoggingRpc(final LoggingOptions options) throws IOException {
|| NoCredentials.getInstance().equals(options.getCredentials())) {
ManagedChannel managedChannel =
ManagedChannelBuilder.forTarget(options.getHost())
.usePlaintext(true)
.usePlaintext()
.executor(executor)
.build();
TransportChannel transportChannel = GrpcTransportChannel.create(managedChannel);
Expand Down Expand Up @@ -189,7 +190,8 @@ public V apply(ApiException exception) {
}
throw new LoggingException(exception);
}
});
},
MoreExecutors.directExecutor());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ public void testListLogEntries() {
EasyMock.replay(rpcFactoryMock);
logging = options.getService();
ListLogEntriesRequest request =
ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build();
ListLogEntriesRequest.newBuilder().addResourceNames(PROJECT_PB).build();
List<LogEntry> entriesList = ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2);
ListLogEntriesResponse response =
ListLogEntriesResponse.newBuilder()
Expand All @@ -1314,9 +1314,12 @@ public void testListLogEntriesNextPage() throws ExecutionException, InterruptedE
EasyMock.replay(rpcFactoryMock);
logging = options.getService();
ListLogEntriesRequest request1 =
ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build();
ListLogEntriesRequest.newBuilder().addResourceNames(PROJECT_PB).build();
ListLogEntriesRequest request2 =
ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).setPageToken(cursor1).build();
ListLogEntriesRequest.newBuilder()
.addResourceNames(PROJECT_PB)
.setPageToken(cursor1)
.build();
List<LogEntry> descriptorList1 = ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2);
List<LogEntry> descriptorList2 = ImmutableList.of(LOG_ENTRY1);
ListLogEntriesResponse response1 =
Expand Down Expand Up @@ -1351,7 +1354,7 @@ public void testListLogEntriesEmpty() {
EasyMock.replay(rpcFactoryMock);
logging = options.getService();
ListLogEntriesRequest request =
ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build();
ListLogEntriesRequest.newBuilder().addResourceNames(PROJECT_PB).build();
List<LogEntry> entriesList = ImmutableList.of();
ListLogEntriesResponse response =
ListLogEntriesResponse.newBuilder()
Expand All @@ -1373,7 +1376,7 @@ public void testListLogEntriesWithOptions() {
logging = options.getService();
ListLogEntriesRequest request =
ListLogEntriesRequest.newBuilder()
.addProjectIds(PROJECT)
.addResourceNames(PROJECT_PB)
.setOrderBy("timestamp desc")
.setFilter("logName:syslog")
.build();
Expand All @@ -1400,7 +1403,7 @@ public void testListLogEntriesAsync() throws ExecutionException, InterruptedExce
EasyMock.replay(rpcFactoryMock);
logging = options.getService();
ListLogEntriesRequest request =
ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build();
ListLogEntriesRequest.newBuilder().addResourceNames(PROJECT_PB).build();
List<LogEntry> entriesList = ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2);
ListLogEntriesResponse response =
ListLogEntriesResponse.newBuilder()
Expand All @@ -1421,9 +1424,12 @@ public void testListLogEntriesAsyncNextPage() {
EasyMock.replay(rpcFactoryMock);
logging = options.getService();
ListLogEntriesRequest request1 =
ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build();
ListLogEntriesRequest.newBuilder().addResourceNames(PROJECT_PB).build();
ListLogEntriesRequest request2 =
ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).setPageToken(cursor1).build();
ListLogEntriesRequest.newBuilder()
.addResourceNames(PROJECT_PB)
.setPageToken(cursor1)
.build();
List<LogEntry> descriptorList1 = ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2);
List<LogEntry> descriptorList2 = ImmutableList.of(LOG_ENTRY1);
ListLogEntriesResponse response1 =
Expand Down Expand Up @@ -1458,7 +1464,7 @@ public void testListLogEntriesAyncEmpty() throws ExecutionException, Interrupted
EasyMock.replay(rpcFactoryMock);
logging = options.getService();
ListLogEntriesRequest request =
ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build();
ListLogEntriesRequest.newBuilder().addResourceNames(PROJECT_PB).build();
List<LogEntry> entriesList = ImmutableList.of();
ListLogEntriesResponse response =
ListLogEntriesResponse.newBuilder()
Expand All @@ -1480,7 +1486,7 @@ public void testListLogEntriesAsyncWithOptions() throws ExecutionException, Inte
logging = options.getService();
ListLogEntriesRequest request =
ListLogEntriesRequest.newBuilder()
.addProjectIds(PROJECT)
.addResourceNames(PROJECT_PB)
.setOrderBy("timestamp desc")
.setFilter("logName:syslog")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public LocalLoggingImpl getLoggingImpl() {
}
/** Creates a channel for making requests to the in-memory service. */
public ManagedChannel createChannel() {
return InProcessChannelBuilder.forName(address).usePlaintext(true).build();
return InProcessChannelBuilder.forName(address).usePlaintext().build();
}
/** Shuts down the in-memory service. */
public void shutdownNow() {
Expand Down

0 comments on commit af8ee56

Please sign in to comment.