Merge branch 'amnon/commitlogstab' of github.com:cloudius-systems/urchin-jmx-dev
Amnon says: "This adds the CommitLogMBean, GossiperMbean and EndpointSnitchInfoMbean stabs to the JMX API, the MBeans are available via Console but returns empty response."
This commit is contained in:
commit
fd244644e9
@ -4,6 +4,10 @@
|
||||
package com.cloudius.urchin.main;
|
||||
|
||||
import com.cloudius.urchin.api.APIClient;
|
||||
|
||||
import org.apache.cassandra.db.commitlog.CommitLog;
|
||||
import org.apache.cassandra.gms.Gossiper;
|
||||
import org.apache.cassandra.locator.EndpointSnitchInfo;
|
||||
import org.apache.cassandra.net.MessagingService;
|
||||
import org.apache.cassandra.service.StorageService;
|
||||
|
||||
@ -14,6 +18,9 @@ public class Main {
|
||||
System.out.println("Starting the JMX server");
|
||||
StorageService.getInstance();
|
||||
MessagingService.getInstance();
|
||||
CommitLog.getInstance();
|
||||
Gossiper.getInstance();
|
||||
EndpointSnitchInfo.getInstance();
|
||||
Thread.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
123
src/main/java/org/apache/cassandra/db/commitlog/CommitLog.java
Normal file
123
src/main/java/org/apache/cassandra/db/commitlog/CommitLog.java
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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.db.commitlog;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.*;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import com.cloudius.urchin.api.APIClient;
|
||||
|
||||
/*
|
||||
* Commit Log tracks every write operation into the system. The aim of the commit log is to be able to
|
||||
* successfully recover data that was not stored to disk via the Memtable.
|
||||
*/
|
||||
public class CommitLog implements CommitLogMBean {
|
||||
|
||||
private static final java.util.logging.Logger logger = java.util.logging.Logger
|
||||
.getLogger(CommitLog.class.getName());
|
||||
|
||||
private APIClient c = new APIClient();
|
||||
|
||||
public void log(String str) {
|
||||
System.out.println(str);
|
||||
logger.info(str);
|
||||
}
|
||||
|
||||
private static final CommitLog instance = new CommitLog();
|
||||
|
||||
public static CommitLog getInstance() {
|
||||
return instance;
|
||||
}
|
||||
private CommitLog() {
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
try {
|
||||
mbs.registerMBean(this, new ObjectName(
|
||||
"org.apache.cassandra.db:type=Commitlog"));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of completed tasks
|
||||
*
|
||||
* @see org.apache.cassandra.metrics.CommitLogMetrics#completedTasks
|
||||
*/
|
||||
@Deprecated
|
||||
public long getCompletedTasks() {
|
||||
log(" getCompletedTasks()");
|
||||
return c.getLongValue("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of tasks waiting to be executed
|
||||
*
|
||||
* @see org.apache.cassandra.metrics.CommitLogMetrics#pendingTasks
|
||||
*/
|
||||
@Deprecated
|
||||
public long getPendingTasks() {
|
||||
log(" getPendingTasks()");
|
||||
return c.getLongValue("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current size used by all the commitlog segments.
|
||||
*
|
||||
* @see org.apache.cassandra.metrics.CommitLogMetrics#totalCommitLogSize
|
||||
*/
|
||||
@Deprecated
|
||||
public long getTotalCommitlogSize() {
|
||||
log(" getTotalCommitlogSize()");
|
||||
return c.getLongValue("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover a single file.
|
||||
*/
|
||||
public void recover(String path) throws IOException {
|
||||
log(" recover(String path) throws IOException");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return file names (not full paths) of active commit log segments
|
||||
* (segments containing unflushed data)
|
||||
*/
|
||||
public List<String> getActiveSegmentNames() {
|
||||
log(" getActiveSegmentNames()");
|
||||
return c.getListStrValue("");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Files which are pending for archival attempt. Does NOT include
|
||||
* failed archive attempts.
|
||||
*/
|
||||
public List<String> getArchivingSegmentNames() {
|
||||
log(" getArchivingSegmentNames()");
|
||||
return c.getListStrValue("");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.db.commitlog;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface CommitLogMBean {
|
||||
/**
|
||||
* Get the number of completed tasks
|
||||
*
|
||||
* @see org.apache.cassandra.metrics.CommitLogMetrics#completedTasks
|
||||
*/
|
||||
@Deprecated
|
||||
public long getCompletedTasks();
|
||||
|
||||
/**
|
||||
* Get the number of tasks waiting to be executed
|
||||
*
|
||||
* @see org.apache.cassandra.metrics.CommitLogMetrics#pendingTasks
|
||||
*/
|
||||
@Deprecated
|
||||
public long getPendingTasks();
|
||||
|
||||
/**
|
||||
* Get the current size used by all the commitlog segments.
|
||||
*
|
||||
* @see org.apache.cassandra.metrics.CommitLogMetrics#totalCommitLogSize
|
||||
*/
|
||||
@Deprecated
|
||||
public long getTotalCommitlogSize();
|
||||
|
||||
/**
|
||||
* Recover a single file.
|
||||
*/
|
||||
public void recover(String path) throws IOException;
|
||||
|
||||
/**
|
||||
* @return file names (not full paths) of active commit log segments
|
||||
* (segments containing unflushed data)
|
||||
*/
|
||||
public List<String> getActiveSegmentNames();
|
||||
|
||||
/**
|
||||
* @return Files which are pending for archival attempt. Does NOT include
|
||||
* failed archive attempts.
|
||||
*/
|
||||
public List<String> getArchivingSegmentNames();
|
||||
}
|
98
src/main/java/org/apache/cassandra/gms/Gossiper.java
Normal file
98
src/main/java/org/apache/cassandra/gms/Gossiper.java
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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.gms;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.UnknownHostException;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import com.cloudius.urchin.api.APIClient;
|
||||
|
||||
/**
|
||||
* This module is responsible for Gossiping information for the local endpoint.
|
||||
* This abstraction maintains the list of live and dead endpoints. Periodically
|
||||
* i.e. every 1 second this module chooses a random node and initiates a round
|
||||
* of Gossip with it. A round of Gossip involves 3 rounds of messaging. For
|
||||
* instance if node A wants to initiate a round of Gossip with node B it starts
|
||||
* off by sending node B a GossipDigestSynMessage. Node B on receipt of this
|
||||
* message sends node A a GossipDigestAckMessage. On receipt of this message
|
||||
* node A sends node B a GossipDigestAck2Message which completes a round of
|
||||
* Gossip. This module as and when it hears one of the three above mentioned
|
||||
* messages updates the Failure Detector with the liveness information. Upon
|
||||
* hearing a GossipShutdownMessage, this module will instantly mark the remote
|
||||
* node as down in the Failure Detector.
|
||||
*/
|
||||
|
||||
public class Gossiper implements GossiperMBean {
|
||||
public static final String MBEAN_NAME = "org.apache.cassandra.net:type=Gossiper";
|
||||
|
||||
private static final java.util.logging.Logger logger = java.util.logging.Logger
|
||||
.getLogger(Gossiper.class.getName());
|
||||
|
||||
private APIClient c = new APIClient();
|
||||
|
||||
public void log(String str) {
|
||||
System.out.println(str);
|
||||
logger.info(str);
|
||||
}
|
||||
|
||||
private static final Gossiper instance = new Gossiper();
|
||||
|
||||
public static Gossiper getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Gossiper() {
|
||||
|
||||
// Register this instance with JMX
|
||||
try {
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
mbs.registerMBean(this, new ObjectName(MBEAN_NAME));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public long getEndpointDowntime(String address) throws UnknownHostException {
|
||||
log(" getEndpointDowntime(String address) throws UnknownHostException");
|
||||
return c.getLongValue("");
|
||||
}
|
||||
|
||||
public int getCurrentGenerationNumber(String address)
|
||||
throws UnknownHostException {
|
||||
log(" getCurrentGenerationNumber(String address) throws UnknownHostException");
|
||||
return c.getIntValue("");
|
||||
}
|
||||
|
||||
public void unsafeAssassinateEndpoint(String address)
|
||||
throws UnknownHostException {
|
||||
log(" unsafeAssassinateEndpoint(String address) throws UnknownHostException");
|
||||
}
|
||||
|
||||
public void assassinateEndpoint(String address) throws UnknownHostException {
|
||||
log(" assassinateEndpoint(String address) throws UnknownHostException");
|
||||
}
|
||||
|
||||
}
|
32
src/main/java/org/apache/cassandra/gms/GossiperMBean.java
Normal file
32
src/main/java/org/apache/cassandra/gms/GossiperMBean.java
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.gms;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public interface GossiperMBean
|
||||
{
|
||||
public long getEndpointDowntime(String address) throws UnknownHostException;
|
||||
|
||||
public int getCurrentGenerationNumber(String address) throws UnknownHostException;
|
||||
|
||||
public void unsafeAssassinateEndpoint(String address) throws UnknownHostException;
|
||||
|
||||
public void assassinateEndpoint(String address) throws UnknownHostException;
|
||||
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.locator;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import com.cloudius.urchin.api.APIClient;
|
||||
|
||||
public class EndpointSnitchInfo implements EndpointSnitchInfoMBean {
|
||||
private static final java.util.logging.Logger logger = java.util.logging.Logger
|
||||
.getLogger(EndpointSnitchInfo.class.getName());
|
||||
|
||||
private APIClient c = new APIClient();
|
||||
|
||||
public void log(String str) {
|
||||
System.out.println(str);
|
||||
logger.info(str);
|
||||
}
|
||||
|
||||
private static final EndpointSnitchInfo instance = new EndpointSnitchInfo();
|
||||
|
||||
public static EndpointSnitchInfo getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private EndpointSnitchInfo() {
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
try {
|
||||
mbs.registerMBean(new EndpointSnitchInfo(), new ObjectName(
|
||||
"org.apache.cassandra.db:type=EndpointSnitchInfo"));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the Rack name depending on the respective snitch used, given the
|
||||
* host name/ip
|
||||
*
|
||||
* @param host
|
||||
* @throws UnknownHostException
|
||||
*/
|
||||
public String getRack(String host) throws UnknownHostException {
|
||||
log(" getRack(String host) throws UnknownHostException");
|
||||
return c.getStringValue("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the Datacenter name depending on the respective snitch used,
|
||||
* given the hostname/ip
|
||||
*
|
||||
* @param host
|
||||
* @throws UnknownHostException
|
||||
*/
|
||||
public String getDatacenter(String host) throws UnknownHostException {
|
||||
log(" getDatacenter(String host) throws UnknownHostException");
|
||||
return c.getStringValue("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the snitch name of the cluster
|
||||
*
|
||||
* @return Snitch name
|
||||
*/
|
||||
public String getSnitchName() {
|
||||
log(" getSnitchName()");
|
||||
return c.getStringValue("");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.locator;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* MBean exposing standard Snitch info
|
||||
*/
|
||||
public interface EndpointSnitchInfoMBean
|
||||
{
|
||||
/**
|
||||
* Provides the Rack name depending on the respective snitch used, given the host name/ip
|
||||
* @param host
|
||||
* @throws UnknownHostException
|
||||
*/
|
||||
public String getRack(String host) throws UnknownHostException;
|
||||
|
||||
/**
|
||||
* Provides the Datacenter name depending on the respective snitch used, given the hostname/ip
|
||||
* @param host
|
||||
* @throws UnknownHostException
|
||||
*/
|
||||
public String getDatacenter(String host) throws UnknownHostException;
|
||||
|
||||
|
||||
/**
|
||||
* Provides the snitch name of the cluster
|
||||
* @return Snitch name
|
||||
*/
|
||||
public String getSnitchName();
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user