Add the MessagingServiceMBean
This is the skeleton implementation for the MessagingService MBean. More functionality will be add when it will be added to the API.
This commit is contained in:
parent
c64b4b6e56
commit
5039f0603b
@ -4,6 +4,7 @@
|
|||||||
package com.cloudius.main;
|
package com.cloudius.main;
|
||||||
|
|
||||||
import com.cloudius.api.APIClient;
|
import com.cloudius.api.APIClient;
|
||||||
|
import org.apache.cassandra.net.MessagingService;
|
||||||
import org.apache.cassandra.service.StorageService;
|
import org.apache.cassandra.service.StorageService;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
@ -12,6 +13,7 @@ public class Main {
|
|||||||
System.out.println("Connecting to " + APIClient.getBaseUrl());
|
System.out.println("Connecting to " + APIClient.getBaseUrl());
|
||||||
System.out.println("Starting the JMX server");
|
System.out.println("Starting the JMX server");
|
||||||
StorageService.getInstance();
|
StorageService.getInstance();
|
||||||
|
MessagingService.getInstance();
|
||||||
Thread.sleep(Long.MAX_VALUE);
|
Thread.sleep(Long.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
161
src/main/java/org/apache/cassandra/net/MessagingService.java
Normal file
161
src/main/java/org/apache/cassandra/net/MessagingService.java
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright 2015 Cloudius Systems
|
||||||
|
*
|
||||||
|
* Modified by Cloudius Systems
|
||||||
|
*/
|
||||||
|
package org.apache.cassandra.net;
|
||||||
|
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.net.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import javax.management.MBeanServer;
|
||||||
|
import javax.management.ObjectName;
|
||||||
|
|
||||||
|
import com.cloudius.api.APIClient;
|
||||||
|
|
||||||
|
public final class MessagingService implements MessagingServiceMBean {
|
||||||
|
public static final String MBEAN_NAME = "org.apache.cassandra.net:type=MessagingService";
|
||||||
|
private static final java.util.logging.Logger logger = java.util.logging.Logger
|
||||||
|
.getLogger(MessagingService.class.getName());
|
||||||
|
|
||||||
|
private APIClient c = new APIClient();
|
||||||
|
|
||||||
|
private final ObjectName jmxObjectName;
|
||||||
|
|
||||||
|
public void log(String str) {
|
||||||
|
System.out.println(str);
|
||||||
|
logger.info(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessagingService() {
|
||||||
|
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||||
|
try {
|
||||||
|
jmxObjectName = new ObjectName(MBEAN_NAME);
|
||||||
|
mbs.registerMBean(this, jmxObjectName);
|
||||||
|
// mbs.registerMBean(StreamManager.instance, new ObjectName(
|
||||||
|
// StreamManager.OBJECT_NAME));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static MessagingService instance = new MessagingService();
|
||||||
|
|
||||||
|
public static MessagingService getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pending tasks for Command(Mutations, Read etc) TCP Connections
|
||||||
|
*/
|
||||||
|
public Map<String, Integer> getCommandPendingTasks() {
|
||||||
|
log(" getCommandPendingTasks()");
|
||||||
|
return c.getMapStringIntegerValue("/messaging_service/messages/pending");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Completed tasks for Command(Mutations, Read etc) TCP Connections
|
||||||
|
*/
|
||||||
|
public Map<String, Long> getCommandCompletedTasks() {
|
||||||
|
System.out.println("getCommandCompletedTasks!");
|
||||||
|
Map<String, Long> res = c
|
||||||
|
.getListMapStringLongValue("/messaging_service/messages/sent");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dropped tasks for Command(Mutations, Read etc) TCP Connections
|
||||||
|
*/
|
||||||
|
public Map<String, Long> getCommandDroppedTasks() {
|
||||||
|
log(" getCommandDroppedTasks()");
|
||||||
|
return c.getMapStringLongValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pending tasks for Response(GOSSIP & RESPONSE) TCP Connections
|
||||||
|
*/
|
||||||
|
public Map<String, Integer> getResponsePendingTasks() {
|
||||||
|
log(" getResponsePendingTasks()");
|
||||||
|
return c.getMapStringIntegerValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Completed tasks for Response(GOSSIP & RESPONSE) TCP Connections
|
||||||
|
*/
|
||||||
|
public Map<String, Long> getResponseCompletedTasks() {
|
||||||
|
log(" getResponseCompletedTasks()");
|
||||||
|
return c.getMapStringLongValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dropped message counts for server lifetime
|
||||||
|
*/
|
||||||
|
public Map<String, Integer> getDroppedMessages() {
|
||||||
|
log(" getDroppedMessages()");
|
||||||
|
return c.getMapStringIntegerValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dropped message counts since last called
|
||||||
|
*/
|
||||||
|
public Map<String, Integer> getRecentlyDroppedMessages() {
|
||||||
|
log(" getRecentlyDroppedMessages()");
|
||||||
|
return c.getMapStringIntegerValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total number of timeouts happened on this node
|
||||||
|
*/
|
||||||
|
public long getTotalTimeouts() {
|
||||||
|
log(" getTotalTimeouts()");
|
||||||
|
return c.getLongValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of timeouts per host
|
||||||
|
*/
|
||||||
|
public Map<String, Long> getTimeoutsPerHost() {
|
||||||
|
log(" getTimeoutsPerHost()");
|
||||||
|
return c.getMapStringLongValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of timeouts since last check.
|
||||||
|
*/
|
||||||
|
public long getRecentTotalTimouts() {
|
||||||
|
log(" getRecentTotalTimouts()");
|
||||||
|
return c.getLongValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of timeouts since last check per host.
|
||||||
|
*/
|
||||||
|
public Map<String, Long> getRecentTimeoutsPerHost() {
|
||||||
|
log(" getRecentTimeoutsPerHost()");
|
||||||
|
return c.getMapStringLongValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVersion(String address) throws UnknownHostException {
|
||||||
|
log(" getVersion(String address) throws UnknownHostException");
|
||||||
|
return c.getIntValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* 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.net;
|
||||||
|
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MBean exposing MessagingService metrics. - OutboundConnectionPools -
|
||||||
|
* Command/Response - Pending/Completed Tasks
|
||||||
|
*/
|
||||||
|
public interface MessagingServiceMBean {
|
||||||
|
/**
|
||||||
|
* Pending tasks for Command(Mutations, Read etc) TCP Connections
|
||||||
|
*/
|
||||||
|
public Map<String, Integer> getCommandPendingTasks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Completed tasks for Command(Mutations, Read etc) TCP Connections
|
||||||
|
*/
|
||||||
|
public Map<String, Long> getCommandCompletedTasks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dropped tasks for Command(Mutations, Read etc) TCP Connections
|
||||||
|
*/
|
||||||
|
public Map<String, Long> getCommandDroppedTasks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pending tasks for Response(GOSSIP & RESPONSE) TCP Connections
|
||||||
|
*/
|
||||||
|
public Map<String, Integer> getResponsePendingTasks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Completed tasks for Response(GOSSIP & RESPONSE) TCP Connections
|
||||||
|
*/
|
||||||
|
public Map<String, Long> getResponseCompletedTasks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dropped message counts for server lifetime
|
||||||
|
*/
|
||||||
|
public Map<String, Integer> getDroppedMessages();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dropped message counts since last called
|
||||||
|
*/
|
||||||
|
public Map<String, Integer> getRecentlyDroppedMessages();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total number of timeouts happened on this node
|
||||||
|
*/
|
||||||
|
public long getTotalTimeouts();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of timeouts per host
|
||||||
|
*/
|
||||||
|
public Map<String, Long> getTimeoutsPerHost();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of timeouts since last check.
|
||||||
|
*/
|
||||||
|
public long getRecentTotalTimouts();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of timeouts since last check per host.
|
||||||
|
*/
|
||||||
|
public Map<String, Long> getRecentTimeoutsPerHost();
|
||||||
|
|
||||||
|
public int getVersion(String address) throws UnknownHostException;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user