Commit 95216790 authored by Julien Muchembled's avatar Julien Muchembled

neoctl: new 'print ids' command

parent b08a8600
......@@ -62,6 +62,8 @@ class AdminEventHandler(EventHandler):
master_node = self.app.master_node
conn.answer(Packets.AnswerPrimary(master_node.getUUID()))
askLastIDs = forward_ask(Packets.AskLastIDs)
askLastTransaction = forward_ask(Packets.AskLastTransaction)
addPendingNodes = forward_ask(Packets.AddPendingNodes)
tweakPartitionTable = forward_ask(Packets.TweakPartitionTable)
setClusterState = forward_ask(Packets.SetClusterState)
......@@ -90,7 +92,7 @@ class MasterEventHandler(EventHandler):
def dispatch(self, conn, packet, kw={}):
if 'conn' in kw:
# expected answer
if packet.isError():
if packet.isResponse():
packet.setId(kw['msg_id'])
kw['conn'].answer(packet)
else:
......@@ -126,3 +128,4 @@ class MasterEventHandler(EventHandler):
class MasterRequestEventHandler(EventHandler):
""" This class handle all answer from primary master node"""
# XXX: to be deleted ?
......@@ -62,6 +62,18 @@ class MasterHandler(EventHandler):
state = self.app.getClusterState()
conn.answer(Packets.AnswerClusterState(state))
def askLastIDs(self, conn):
app = self.app
conn.answer(Packets.AnswerLastIDs(
app.tm.getLastOID(),
app.tm.getLastTID(),
app.pt.getID(),
app.backup_tid))
def askLastTransaction(self, conn):
conn.answer(Packets.AnswerLastTransaction(
self.app.getLastTransaction()))
def askNodeInformation(self, conn):
nm = self.app.nm
node_list = []
......
......@@ -104,10 +104,6 @@ class ClientServiceHandler(MasterHandler):
else:
conn.answer(Packets.AnswerPack(False))
def askLastTransaction(self, conn):
conn.answer(Packets.AnswerLastTransaction(
self.app.getLastTransaction()))
def abortTransaction(self, conn, tid):
self.app.tm.remove(conn.getUUID(), tid)
......@@ -49,14 +49,6 @@ class StorageServiceHandler(BaseServiceHandler):
if app.packing is not None:
self.answerPack(conn, False)
def askLastIDs(self, conn):
app = self.app
conn.answer(Packets.AnswerLastIDs(
app.tm.getLastOID(),
app.tm.getLastTID(),
app.pt.getID(),
app.backup_tid))
def askUnfinishedTransactions(self, conn):
app = self.app
if app.backup_tid:
......
......@@ -16,12 +16,13 @@
from operator import itemgetter
from .neoctl import NeoCTL, NotReadyException
from neo.lib.util import bin, p64
from neo.lib.util import bin, p64, u64
from neo.lib.protocol import uuid_str, ClusterStates, NodeTypes, \
UUID_NAMESPACES, ZERO_TID
action_dict = {
'print': {
'ids': 'getLastIds',
'pt': 'getPartitionRowList',
'node': 'getNodeList',
'cluster': 'getClusterState',
......@@ -77,6 +78,17 @@ class TerminalNeoCTL(object):
for node_type, address, uuid, state in node_list)
# Actual actions
def getLastIds(self, params):
"""
Get last ids.
"""
assert not params
r = self.neoctl.getLastIds()
if r[3]:
return "last_tid = 0x%x" % u64(self.neoctl.getLastTransaction())
return "last_oid = 0x%x\nlast_tid = 0x%x\nlast_ptid = %u" % (
u64(r[0]), u64(r[1]), r[2])
def getPartitionRowList(self, params):
"""
Get a list of partition rows, bounded by min & max and involving
......
......@@ -59,3 +59,5 @@ class CommandEventHandler(EventHandler):
answerNodeList = __answer(Packets.AnswerNodeList)
answerClusterState = __answer(Packets.AnswerClusterState)
answerPrimary = __answer(Packets.AnswerPrimary)
answerLastIDs = __answer(Packets.AnswerLastIDs)
answerLastTransaction = __answer(Packets.AnswerLastTransaction)
......@@ -119,6 +119,18 @@ class NeoCTL(object):
raise RuntimeError(response)
return response[1]
def getLastIds(self):
response = self.__ask(Packets.AskLastIDs())
if response[0] != Packets.AnswerLastIDs:
raise RuntimeError(response)
return response[1:]
def getLastTransaction(self):
response = self.__ask(Packets.AskLastTransaction())
if response[0] != Packets.AnswerLastTransaction:
raise RuntimeError(response)
return response[1]
def getNodeList(self, node_type=None):
"""
Get a list of nodes, filtering with given type.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment