Commit b81ae60a authored by Julien Muchembled's avatar Julien Muchembled

Start renaming UUID into NID, because node IDs are not 128 bits length anymore

SQL tables can be upgraded using:
  UPDATE config SET name = 'nid' WHERE name = 'uuid';

then for MySQL:
  ALTER TABLE pt CHANGE uuid nid INT NOT NULL;

or SQLite:
  ALTER TABLE pt RENAME TO old_pt;
  CREATE TABLE pt (rid INTEGER NOT NULL, nid INTEGER NOT NULL, state INTEGER NOT NULL, PRIMARY KEY (rid, nid));
  INSERT INTO pt SELECT * from old_pt;
  DROP TABLE old_pt;
parent 52c5d862
......@@ -23,6 +23,7 @@ RC - Review output of pylint (CODE)
Consider the need to implement a keep-alive system (packets sent
automatically when there is no activity on the connection for a period
of time).
- Finish renaming UUID into NID everywhere (CODE)
- Consider using multicast for cluster-wide notifications. (BANDWITH)
Currently, multi-receivers notifications are sent in unicast to each
receiver. Multicast should be used.
......
......@@ -19,11 +19,11 @@ SQL commands to migrate each storage from NEO 0.10.x::
UPDATE trans SET ttid=tid;
ALTER TABLE ttrans ADD COLUMN ttid BIGINT UNSIGNED NOT NULL;
ALTER TABLE config MODIFY name VARBINARY(255) NOT NULL;
CREATE TEMPORARY TABLE uuid (new INT NOT NULL AUTO_INCREMENT PRIMARY KEY, old CHAR(32) NOT NULL, KEY (old)) ENGINE = InnoDB SELECT DISTINCT uuid as old FROM pt ORDER BY uuid;
ALTER TABLE pt DROP PRIMARY KEY, CHANGE uuid old CHAR(32) NOT NULL, ADD uuid INT NOT NULL after rid;
UPDATE pt, uuid SET pt.uuid=uuid.new, state=state-1 WHERE pt.old=uuid.old;
ALTER TABLE pt DROP old, ADD PRIMARY KEY (rid, uuid);
UPDATE config, uuid SET config.value=uuid.new WHERE config.name='uuid' AND uuid.old=config.value;
CREATE TEMPORARY TABLE nid (new INT NOT NULL AUTO_INCREMENT PRIMARY KEY, old CHAR(32) NOT NULL, KEY (old)) ENGINE = InnoDB SELECT DISTINCT uuid as old FROM pt ORDER BY uuid;
ALTER TABLE pt DROP PRIMARY KEY, ADD nid INT NOT NULL after rid;
UPDATE pt, nid SET pt.nid=nid.new, state=state-1 WHERE pt.uuid=nid.old;
ALTER TABLE pt DROP uuid, ADD PRIMARY KEY (rid, nid);
UPDATE config, nid SET config.name='nid', config.value=nid.new WHERE config.name='uuid' AND nid.old=config.value;
DELETE FROM config WHERE name='loid';
NEO 0.10
......
......@@ -72,17 +72,17 @@ class DatabaseManager(object):
def getUUID(self):
"""
Load an UUID from a database.
Load a NID from a database.
"""
uuid = self.getConfiguration('uuid')
if uuid is not None:
return int(uuid)
nid = self.getConfiguration('nid')
if nid is not None:
return int(nid)
def setUUID(self, uuid):
def setUUID(self, nid):
"""
Store an UUID into a database.
Store a NID into a database.
"""
self.setConfiguration('uuid', str(uuid))
self.setConfiguration('nid', str(nid))
def getNumPartitions(self):
"""
......@@ -151,7 +151,7 @@ class DatabaseManager(object):
def getPartitionTable(self):
"""Return a whole partition table as a sequence of rows. Each row
is again a tuple of an offset (row ID), an UUID of a storage
is again a tuple of an offset (row ID), the NID of a storage
node, and a cell state."""
raise NotImplementedError
......@@ -238,7 +238,7 @@ class DatabaseManager(object):
def changePartitionTable(self, ptid, cell_list):
"""Change a part of a partition table. The list of cells is
a tuple of tuples, each of which consists of an offset (row ID),
an UUID of a storage node, and a cell state. The Partition
the NID of a storage node, and a cell state. The Partition
Table ID must be stored as well."""
raise NotImplementedError
......@@ -249,8 +249,8 @@ class DatabaseManager(object):
raise NotImplementedError
def dropPartitions(self, offset_list):
""" Drop any data of non-assigned partitions for a given UUID """
raise NotImplementedError('this method must be overriden')
"""Delete all data for specified partitions"""
raise NotImplementedError
def dropUnfinishedData(self):
"""Drop any unfinished data from a database."""
......@@ -272,7 +272,7 @@ class DatabaseManager(object):
'unreferenced' means:
- not in self._uncommitted_data
- and not referenced by a fully-committed object (storage should have
an index or a refcound of all data ids of all objects)
an index or a refcount of all data ids of all objects)
"""
raise NotImplementedError
......
......@@ -152,9 +152,9 @@ class MySQLDatabaseManager(DatabaseManager):
# The table "pt" stores a partition table.
q("""CREATE TABLE IF NOT EXISTS pt (
rid INT UNSIGNED NOT NULL,
uuid INT NOT NULL,
nid INT NOT NULL,
state TINYINT UNSIGNED NOT NULL,
PRIMARY KEY (rid, uuid)
PRIMARY KEY (rid, nid)
) ENGINE = InnoDB""")
p = self._use_partition and """ PARTITION BY LIST (partition) (
......@@ -323,17 +323,17 @@ class MySQLDatabaseManager(DatabaseManager):
q = self.query
if reset:
q("TRUNCATE pt")
for offset, uuid, state in cell_list:
for offset, nid, state in cell_list:
# TODO: this logic should move out of database manager
# add 'dropCells(cell_list)' to API and use one query
if state == CellStates.DISCARDED:
q("DELETE FROM pt WHERE rid = %d AND uuid = %d"
% (offset, uuid))
q("DELETE FROM pt WHERE rid = %d AND nid = %d"
% (offset, nid))
else:
offset_list.append(offset)
q("INSERT INTO pt VALUES (%d, %d, %d)"
" ON DUPLICATE KEY UPDATE state = %d"
% (offset, uuid, state, state))
% (offset, nid, state, state))
self.setPTID(ptid)
if self._use_partition:
for offset in offset_list:
......
......@@ -112,9 +112,9 @@ class SQLiteDatabaseManager(DatabaseManager):
# The table "pt" stores a partition table.
q("""CREATE TABLE IF NOT EXISTS pt (
rid INTEGER NOT NULL,
uuid INTEGER NOT NULL,
nid INTEGER NOT NULL,
state INTEGER NOT NULL,
PRIMARY KEY (rid, uuid))
PRIMARY KEY (rid, nid))
""")
# The table "trans" stores information on committed transactions.
......@@ -277,17 +277,17 @@ class SQLiteDatabaseManager(DatabaseManager):
q = self.query
if reset:
q("DELETE FROM pt")
for offset, uuid, state in cell_list:
for offset, nid, state in cell_list:
# TODO: this logic should move out of database manager
# add 'dropCells(cell_list)' to API and use one query
# WKRD: Why does SQLite need a statement journal file
# whereas we try to replace only 1 value ?
# We don't want to remove the 'NOT NULL' constraint
# so we must simulate a "REPLACE OR FAIL".
q("DELETE FROM pt WHERE rid=? AND uuid=?", (offset, uuid))
q("DELETE FROM pt WHERE rid=? AND nid=?", (offset, nid))
if state != CellStates.DISCARDED:
q("INSERT OR FAIL INTO pt VALUES (?,?,?)",
(offset, uuid, int(state)))
(offset, nid, int(state)))
self.setPTID(ptid)
def changePartitionTable(self, ptid, cell_list):
......
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