frankgh commented on code in PR #166:
URL: https://github.com/apache/cassandra-sidecar/pull/166#discussion_r1933004892
##########
client/src/main/java/org/apache/cassandra/sidecar/client/RequestContext.java:
##########
@@ -537,6 +538,17 @@ public Builder nodeDecommissionRequest()
return request(NODE_DECOMMISSION_REQUEST);
}
+ /**
+ * Sets the {@code request} to be a {@link StreamStatsRequest} and
returns a reference to this Builder
+ * enabling method chaining.
+ *
+ * @return a reference to this Builder
+ */
+ public Builder streamsStatsRequest()
+ {
+ return request(new StreamStatsRequest());
Review Comment:
minor NIT: Can be created once, since it won't ever change for the client.
ie.
```
protected static final StreamStatsRequest STREAM_STATS_REQUEST = new
StreamStatsRequest();
```
Obviously there are drawbacks with this approach, so that's why it's a minor
NIT
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/request/StreamStatsRequest.java:
##########
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.sidecar.common.request;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.StreamStatsResponse;
+
+/**
+ * Class response for the StreamsStats API
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
Review Comment:
yeah, this should not be included here. Can we remove it ?
##########
adapters/base/src/main/java/org/apache/cassandra/sidecar/adapters/base/GossipDependentStorageJmxOperations.java:
##########
@@ -146,6 +146,11 @@ public int forceKeyspaceCleanup(int jobs, String
keyspaceName, String... tables)
return delegate.forceKeyspaceCleanup(jobs, keyspaceName, tables);
}
+ public String getOperationMode()
Review Comment:
I guess we have this method available as of
https://github.com/apache/cassandra-sidecar/commit/f45bbacc42990e5196c927ed6169d82cd9faf5f6.
Maybe restore this file since the change is no longer necessary?
##########
adapters/base/src/main/java/org/apache/cassandra/sidecar/adapters/base/CassandraMetricsOperations.java:
##########
@@ -18,33 +18,52 @@
package org.apache.cassandra.sidecar.adapters.base;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import javax.management.openmbean.CompositeData;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.sidecar.adapters.base.data.SessionInfo;
+import org.apache.cassandra.sidecar.adapters.base.data.StreamState;
import org.apache.cassandra.sidecar.adapters.base.db.ConnectedClientStats;
import
org.apache.cassandra.sidecar.adapters.base.db.ConnectedClientStatsDatabaseAccessor;
import
org.apache.cassandra.sidecar.adapters.base.db.ConnectedClientStatsSummary;
import
org.apache.cassandra.sidecar.adapters.base.db.schema.ConnectedClientsSchema;
import
org.apache.cassandra.sidecar.common.response.ConnectedClientStatsResponse;
import org.apache.cassandra.sidecar.common.response.data.ClientConnectionEntry;
+import org.apache.cassandra.sidecar.common.response.data.StreamsProgressStats;
import org.apache.cassandra.sidecar.common.server.CQLSessionProvider;
+import org.apache.cassandra.sidecar.common.server.JmxClient;
import org.apache.cassandra.sidecar.common.server.MetricsOperations;
import org.jetbrains.annotations.NotNull;
+import static
org.apache.cassandra.sidecar.adapters.base.StreamManagerJmxOperations.STREAM_MANAGER_OBJ_NAME;
+
/**
* Default implementation that pulls methods from the Cassandra Metrics Proxy
*/
public class CassandraMetricsOperations implements MetricsOperations
{
+ private static final Logger LOGGER =
LoggerFactory.getLogger(CassandraStorageOperations.class);
Review Comment:
is this on purpose?
```suggestion
private static final Logger LOGGER =
LoggerFactory.getLogger(CassandraMetricsOperations.class);
```
##########
adapters/base/src/main/java/org/apache/cassandra/sidecar/adapters/base/data/SessionInfo.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.sidecar.adapters.base.data;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.management.openmbean.CompositeData;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * Representation of session info data
+ */
+public class SessionInfo
+{
+ public final String peer;
+ public final int sessionIndex;
+ public final String connecting;
+ /** Immutable collection of receiving summaries */
+ public final List<StreamSummary> receivingSummaries;
+ /** Immutable collection of sending summaries*/
+ public final List<StreamSummary> sendingSummaries;
+ /** Current session state */
+ public final String state;
+ public final List<ProgressInfo> receivingFiles;
+ public final List<ProgressInfo> sendingFiles;
+
+ public SessionInfo(CompositeData data)
+ {
+ this.peer = (String) data.get("peer");
+ this.sessionIndex = (int) data.get("sessionIndex");
+ this.connecting = (String) data.get("connecting");
+ this.receivingSummaries = parseSummaries((CompositeData[])
data.get("receivingSummaries"));
+ this.sendingSummaries = parseSummaries((CompositeData[])
data.get("sendingSummaries"));
+ this.state = (String) data.get("state");
+ this.receivingFiles = parseFiles((CompositeData[])
data.get("receivingFiles"));
+ this.sendingFiles = parseFiles((CompositeData[])
data.get("sendingFiles"));
+ }
+
+ /**
+ * @return total size(in bytes) already received.
+ */
+ public long totalSizeReceived()
+ {
+ return totalSizeInProgress(receivingFiles);
+ }
+
+ /**
+ * @return total size(in bytes) already sent.
+ */
+ public long totalSizeSent()
+ {
+ return totalSizeInProgress(sendingFiles);
+ }
+
+ /**
+ * @return total number of files to receive in the session
+ */
+ public long totalFilesToReceive()
+ {
+ return totalFiles(receivingSummaries);
+ }
+
+ /**
+ * @return total number of files to send in the session
+ */
+ public long totalFilesToSend()
+ {
+ return totalFiles(sendingSummaries);
+ }
+
+ /**
+ * @return total size(in bytes) to receive in the session
+ */
+ public long totalSizeToReceive()
+ {
+ return totalSizes(receivingSummaries);
+ }
+
+ /**
+ * @return total size(in bytes) to send in the session
+ */
+ public long totalSizeToSend()
+ {
+ return totalSizes(sendingSummaries);
+ }
+
+ /**
+ * @return total number of files already received.
+ */
+ public long totalFilesReceived()
+ {
+ return totalFilesCompleted(receivingFiles);
+ }
+
+ /**
+ * @return total number of files already sent.
+ */
+ public long totalFilesSent()
+ {
+ return totalFilesCompleted(sendingFiles);
+ }
+
+ private long totalSizes(List<StreamSummary> summaries)
+ {
+ long total = 0;
+ for (StreamSummary summary : summaries)
+ total += summary.totalSize;
+ return total;
+ }
+
+ private long totalFilesCompleted(List<ProgressInfo> files)
+ {
+ Iterable<ProgressInfo> completed = Iterables.filter(files, input ->
input.isCompleted());
+ return Iterables.size(completed);
Review Comment:
maybe simpler to do ? Any reason why we decide to use Iterables here?
```suggestion
return files.stream()
.filter(ProgressInfo::isCompleted)
.count();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]