public DistributedHashTableStorage( string database, IDistributedHashTableNode distributedHashTableNode) { try { hashTable = new PersistentHashTable.PersistentHashTable(database); hashTable.Initialize(); } catch (Exception) { try { hashTable.Dispose(); } catch { // not much to do if we fail here } throw; } this.distributedHashTableNode = distributedHashTableNode; distributedHashTableNode.Storage = this; Replication = new DistributedHashTableNodeReplication(hashTable); }
public DistributedHashTableStorage( string database, IDistributedHashTableNode distributedHashTableNode) { try { hashTable = new PersistentHashTable.PersistentHashTable(database); hashTable.Initialize(); } catch (Exception) { try { hashTable.Dispose(); } catch { // not much to do if we fail here } throw; } this.distributedHashTableNode = distributedHashTableNode; distributedHashTableNode.Storage = this; Replication = new DistributedHashTableNodeReplication(hashTable); }
public void Start() { hashTable.Initialize(); hashTable.Batch(actions => { var value = actions.Get(new GetRequest { Key = Constants.Topology }).LastOrDefault(); if (value != null) { var topology = MessageStreamIterator <TopologyResultMessage> .FromStreamProvider(() => new MemoryStream(value.Data)) .First(); master.Topology = topology.GetTopology(); master.RefreshEndpoints(); } actions.Commit(); }); listener.Start(); listener.BeginAcceptTcpClient(OnAcceptTcpClient, null); OnTopologyChanged(); }
public void Initialize() { logger.DebugFormat("Initializing msmq subscription storage on: {0}", subscriptionPath); pht.Initialize(); pht.Batch(actions => { var items = actions.GetItems(new GetItemsRequest { Key = SubscriptionsKey }); foreach (var item in items) { object[] msgs; try { msgs = messageSerializer.Deserialize(new MemoryStream(item.Value)); } catch (Exception e) { throw new SubscriptionException("Could not deserialize message from subscription queue", e); } try { currentlyLoadingPersistentData = true; foreach (var msg in msgs) { HandleAdministrativeMessage(new CurrentMessageInformation { AllMessages = msgs, Message = msg, }); } } catch (Exception e) { throw new SubscriptionException("Failed to process subscription records", e); } finally { currentlyLoadingPersistentData = false; } } actions.Commit(); }); }