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