public virtual void Add(Int64 a, Int32 b) { if (!didopen) { throw new Exception("Must Open before writing to Hashtable"); } B12 b12; // = new B12(a, b); b12.A = a; b12.B = b; int slaveID = (int)(b12.A % dslaves.Count); /*if (slaveID < 0 || slaveID >= dslaves.Count) * { * throw new Exception("Slave missing: slaveID needed: " + slaveID.ToString()); * }*/ SlaveInfo slave = dslaves[slaveID]; lock (slave) { if (addbufinitsize > 0) { BufSlaveInfo bslave = (BufSlaveInfo)slave; bslave.EnsureAddBuf_unlocked(addbufinitsize); b12.CopyToArray(buf); bslave.AddBuf_unlocked(buf, 12); } } }
public void Add(IList <byte> key, int keyoffset, IList <byte> value, int valueoffset) { ensureopen("Add"); ensurenotenumd("Add"); ensurenotsortd("Add"); int slaveID = DetermineSlave(key, keyoffset, this.keylen); /*if (slaveID < 0 || slaveID >= dslaves.Count) * { * throw new Exception("Slave missing: slaveID needed: " + slaveID.ToString()); * }*/ SlaveInfo slave = dslaves[slaveID]; lock (slave) { BufSlaveInfo bslave = (BufSlaveInfo)slave; bslave.EnsureAddBuf_unlocked(addbufinitsize); bool flushed = bslave.AddBuf_unlocked(key, keyoffset, this.keylen, value, valueoffset, this.valuelen); if (flushed) { bslave.SlaveErrorCheck(); } } }
internal FixedArrayComboListEnumerator(FixedArrayComboList acl, SlaveInfo slave, byte[] dlldata, string classname, string plugincode) { this.acl = acl; this.slave = slave; this.dlldata = dlldata; this.classname = classname; if (null == plugincode) { plugincode = ""; } this.plugincode = plugincode; }
public virtual void Add(int a, int b) { if (!didopen) { throw new Exception("Must Open before writing to Hashtable"); } B8 b8; // = new B8(a, b); b8.A = a; b8.B = b; //b8.CopyToArray(buf); //int slaveID = DetermineSlave(buf, 8); int slaveID = ((b8.A ^ b8.B) & 0x7FFFFFFF) % dslaves.Count; /*if (slaveID < 0 || slaveID >= dslaves.Count) * { * throw new Exception("Slave missing: slaveID needed: " + slaveID.ToString()); * }*/ SlaveInfo slave = dslaves[slaveID]; lock (slave) { if (addbufinitsize > 0) { BufSlaveInfo bslave = (BufSlaveInfo)slave; bslave.EnsureAddBuf_unlocked(addbufinitsize); b8.CopyToArray(buf); bslave.AddBuf_unlocked(buf, 8); } else { // 'P' for publish/put slave.nstm.WriteByte((byte)'P'); DistObject.ToBytes(Int32.MaxValue, buf, 0); XContent.SendXContent(slave.nstm, buf, 4); b8.CopyToArray(buf); XContent.SendXContent(slave.nstm, buf, 8); // Note: no confirmation } } }
// Returns -1 if no such key. public int Length(byte[] key) { if (!didopen) { throw new Exception("Must Open before writing to Hashtable"); } int slaveID = DetermineSlave(key); if (slaveID < 0 || slaveID >= dslaves.Count) { throw new Exception("Sub process missing: subProcessID needed: " + slaveID.ToString()); } SlaveInfo slave = dslaves[slaveID]; lock (slave) { // 'l' for get length slave.nstm.WriteByte((byte)'l'); XContent.SendXContent(slave.nstm, key); // Replies with tag '+' and xcontent length; or tag '-' if not exists. byte[] result = null; int len; int x = slave.nstm.ReadByte(); if ('+' == x) { result = XContent.ReceiveXBytes(slave.nstm, out len, buf); return(DistObjectBase.BytesToInt(result)); // Only reads first one. } else if ('-' == x) { //result = null; return(-1); } else { throw new Exception("Server returned invalid response for l (Length)"); } } }
// Gives null if no such key. public byte[] Get(byte[] key) { if (!didopen) { throw new Exception("Must Open before reading from Hashtable"); } int slaveID = DetermineSlave(key); if (slaveID < 0 || slaveID >= dslaves.Count) { throw new Exception("Sub process missing: subProcessID needed: " + slaveID.ToString()); } SlaveInfo slave = dslaves[slaveID]; lock (slave) { // 'G' for get slave.nstm.WriteByte((byte)'G'); XContent.SendXContent(slave.nstm, key); // Replies with tag '+' and xcontent value; or tag '-' if not exists. byte[] result = null; int len; int x = slave.nstm.ReadByte(); if ('+' == x) { result = XContent.ReceiveXBytes(slave.nstm, out len, null); // Null buffer for copy. } else if ('-' == x) { //result = null; } else { throw new Exception("Server returned invalid response for G (get)"); } return(result); } }
public virtual void AddBlock(string capacity, string sUserBlockInfo) { if (didopen) { throw new Exception("Attempted to AddBlock after Open"); } // @"H|objectname|200MB|localhost|C:\hashtable_logs0|slaveid=0" string sblockinfo = GetDistObjectTypeChar().ToString() + "|" + ObjectName + "|" + capacity + "|" + sUserBlockInfo; string[] blockinfo = sblockinfo.Split('|'); SlaveInfo slave = createSlaveInfo(); string xslaveid = blockinfo[5]; if ("slaveid=" != xslaveid.Substring(0, 8)) { throw new Exception("AddBlock: sub process ID failure: bad slaveID string: " + xslaveid); } string sslaveID = xslaveid.Substring(8); slave.slaveID = int.Parse(sslaveID); if (slave.slaveID < 0) { throw new Exception("AddBlock: invalid sub process ID: negative value: " + sslaveID); } if (slave.slaveID != dslaves.Count) { throw new Exception("AddBlock: sub process ID not next: found " + sslaveID + " expected " + dslaves.Count.ToString()); } slave.blockinfo = blockinfo; slave.sblockinfo = sblockinfo; dslaves.Add(slave); if (slave.slaveID != dslaves.Count - 1) { throw new Exception("AddBlock: sub process ID sanity check failed"); } }
public void Add(byte[] key, byte[] value) { if (!didopen) { throw new Exception("Must Open before writing to Hashtable"); } int slaveID = DetermineSlave(key); if (slaveID < 0 || slaveID >= dslaves.Count) { throw new Exception("Sub process missing: subProcessID needed: " + slaveID.ToString()); } SlaveInfo slave = dslaves[slaveID]; lock (slave) { // 'P' for publish/put slave.nstm.WriteByte((byte)'P'); XContent.SendXContent(slave.nstm, key); XContent.SendXContent(slave.nstm, value); // Note: no confirmation } }
public void Length(byte[] key, int setlength) { if (!didopen) { throw new Exception("Must Open before writing to Hashtable"); } int slaveID = DetermineSlave(key); if (slaveID < 0 || slaveID >= dslaves.Count) { throw new Exception("Sub process missing: subProcessID needed: " + slaveID.ToString()); } SlaveInfo slave = dslaves[slaveID]; lock (slave) { // 'L' for set length slave.nstm.WriteByte((byte)'L'); XContent.SendXContent(slave.nstm, key); XContent.SendXContent(slave.nstm, DistObjectBase.ToBytes(setlength)); // Note: no confirmation } }
internal LongIntComboListEnumerator(SlaveInfo slave, byte enumid) { this.slave = slave; this.enumid = enumid; }
internal HashtablePartEnumerator(SlaveInfo slave, byte enumid) { this.slave = slave; this.enumid = enumid; }