Exemplo n.º 1
0
def connectedClientInfo(view):
    """given a view subscribed to the client info keyspace, computes all the connected
    clients"""

    clientInfoKeyspace = SharedStateNative.getClientInfoKeyspace()
    k = view.nextKey(Key(clientInfoKeyspace, (NativeJson.lowestValue(), NativeJson.lowestValue())))

    maxId = 0
    tr = set()
    while k is not None:
        if k.keyspace != clientInfoKeyspace.name:
            return tr, maxId
        if view[k].value() != NativeJson.Json('disconnected'):
            tr.add(k[1])
        maxId = max(maxId, view[k].id())
        k = view.nextKey(k)
    return tr, maxId
Exemplo n.º 2
0
def iterKeys(view, keyspace):
    assert view.isFrozen
    key = view.nextKey(
        Key(keyspace,
            tuple(NativeJson.lowestValue()
                  for x in range(keyspace.dimension))))
    while key is not None:
        yield key
        key = view.nextKey(key)
Exemplo n.º 3
0
 def keyspaceIterItems(self, keyspace):
     self.assertSingleThreaded()
     startKey = tuple([NativeJson.lowestValue() for x in range(keyspace.dimension)])
     with SharedState.Transaction(self._view):
         k = self._view.nextKey(SharedState.Key(keyspace, startKey))
         while k is not None and str(k.keyspace) == str(keyspace.name):
             if self._view[k] is not None:
                 yield k, self._view[k].value()
             k = self._view.nextKey(k)
Exemplo n.º 4
0
 def keyspaceIterItems(self, keyspace):
     self.assertSingleThreaded()
     startKey = tuple(
         [NativeJson.lowestValue() for x in range(keyspace.dimension)])
     with SharedState.Transaction(self._view):
         k = self._view.nextKey(SharedState.Key(keyspace, startKey))
         while k is not None and str(k.keyspace) == str(keyspace.name):
             if self._view[k] is not None:
                 yield k, self._view[k].value()
             k = self._view.nextKey(k)
Exemplo n.º 5
0
def connectedClientInfo(view):
    """given a view subscribed to the client info keyspace, computes all the connected
    clients"""

    clientInfoKeyspace = SharedStateNative.getClientInfoKeyspace()
    k = view.nextKey(
        Key(clientInfoKeyspace,
            (NativeJson.lowestValue(), NativeJson.lowestValue())))

    maxId = 0
    tr = set()
    while k is not None:
        if k.keyspace != clientInfoKeyspace.name:
            return tr, maxId
        if view[k].value() != NativeJson.Json('disconnected'):
            tr.add(k[1])
        maxId = max(maxId, view[k].id())
        k = view.nextKey(k)
    return tr, maxId
Exemplo n.º 6
0
def iterKeys(view, keyspace):
    assert view.isFrozen
    key = view.nextKey(Key(keyspace,  tuple(NativeJson.lowestValue() for x in range(keyspace.dimension))))
    while key is not None:
        yield key
        key = view.nextKey(key)