Write a provider into the given store.

@param {Datastore} store
@param {CID} cid
@param {PeerId} peer
@param {number} time
@param {function(Error)} callback
@returns {undefined}

@private
487874
function writeProviderEntry (store, cid, peer, time, callback) {
  const dsKey = [
    makeProviderKey(cid),
    '/',
    utils.encodeBase32(peer.id)
  ].join('')

  store.put(new Key(dsKey), Buffer.from(varint.encode(time)), callback)
}
100893
function subscribe(callback) {
    var id = store._getCurrentCallbackId();
    store._incrementCurFunctionId();
    function unsubscribe() {
      store._callback_objs = store._callback_objs.filter(function (c) {
        return c.id !== id;
      });
      store._removeKeySubscriber(id);
    }
    store._callback_objs.push({ id: id, callback: callback });
    return unsubscribe;
  }
1193766
function dispatchToStores(ids = new Set()) {
	ids.forEach((storeID) => {
		if (this[IS_PENDING][storeID]) {
			return true;
		}

		invokeCallback.call(this, storeID);
	});
}
774951
function (iceServers, options, plugin, ready) {
    var Proto = function PeerConnection () {},
        api = new Proto(),
        id = $.uuid(),
        hasLocalDescription = false,
        hasRemoteDescription = false,
        candidates = [],
        inited = false,
        deferMethods = [],
        events;

    plugin.addRef(api);

    events = {
      addstream: [],
      removestream: [],
      icecandidate: [],
      signalingstatechange: [],
      iceconnectionstatechange: []
    };

    var onAddIceCandidate = function onAddIceCandidate () {/* success */},

        onAddIceCandidateFailed = function onAddIceCandidateFailed (err) {
          OTPlugin.error('Failed to process candidate');
          OTPlugin.error(err);
        },

        processPendingCandidates = function processPendingCandidates () {
          for (var i=0; i<candidates.length; ++i) {
            plugin._.addIceCandidate(id, candidates[i], onAddIceCandidate, onAddIceCandidateFailed);
          }
        },


        deferMethod = function deferMethod (method) {
          return function() {
            if (inited === true) {
              return method.apply(api, arguments);
            }

            deferMethods.push([method, arguments]);
          };
        },

        processDeferredMethods = function processDeferredMethods () {
          var m;
          while ( (m = deferMethods.shift()) ) {
            m[0].apply(api, m[1]);
          }
        },

        triggerEvent = function triggerEvent (/* eventName [, arg1, arg2, ..., argN] */) {
          var args = Array.prototype.slice.call(arguments),
              eventName = args.shift();

          if (!events.hasOwnProperty(eventName)) {
            OTPlugin.error('PeerConnection does not have an event called: ' + eventName);
            return;
          }

          $.forEach(events[eventName], function(listener) {
            listener.apply(null, args);
          });
        },

        bindAndDelegateEvents = function bindAndDelegateEvents (events) {
          for (var name in events) {
            if (events.hasOwnProperty(name)) {
              events[name] = curryCallAsync(events[name]);
            }
          }

          plugin._.on(id, events);
        },

        addStream = function addStream (streamJson) {
          setTimeout(function() {
            var stream = MediaStream.fromJson(streamJson, plugin),
                event = {stream: stream, target: api};

            if (api.onaddstream && $.isFunction(api.onaddstream)) {
              $.callAsync(api.onaddstream, event);
            }

            triggerEvent('addstream', event);
          }, 3000);
        },

        removeStream = function removeStream (streamJson) {
          var stream = MediaStream.fromJson(streamJson, plugin),
              event = {stream: stream, target: api};

          if (api.onremovestream && $.isFunction(api.onremovestream)) {
            $.callAsync(api.onremovestream, event);
          }

          triggerEvent('removestream', event);
        },

        iceCandidate = function iceCandidate (candidateSdp, sdpMid, sdpMLineIndex) {
          var candidate = new OTPlugin.RTCIceCandidate({
            candidate: candidateSdp,
            sdpMid: sdpMid,
            sdpMLineIndex: sdpMLineIndex
          });

          var event = {candidate: candidate, target: api};

          if (api.onicecandidate && $.isFunction(api.onicecandidate)) {
            $.callAsync(api.onicecandidate, event);
          }

          triggerEvent('icecandidate', event);
        },

        signalingStateChange = function signalingStateChange (state) {
          api.signalingState = state;
          var event = {state: state, target: api};

          if (api.onsignalingstatechange &&
                  $.isFunction(api.onsignalingstatechange)) {
            $.callAsync(api.onsignalingstatechange, event);
          }

          triggerEvent('signalingstate', event);
        },

        iceConnectionChange = function iceConnectionChange (state) {
          api.iceConnectionState = state;
          var event = {state: state, target: api};

          if (api.oniceconnectionstatechange &&
                  $.isFunction(api.oniceconnectionstatechange)) {
            $.callAsync(api.oniceconnectionstatechange, event);
          }

          triggerEvent('iceconnectionstatechange', event);
        };

    api.createOffer = deferMethod(function (success, error, constraints) {
      OTPlugin.debug('createOffer', constraints);
      plugin._.createOffer(id, function(type, sdp) {
        success(new OTPlugin.RTCSessionDescription({
          type: type,
          sdp: sdp
        }));
      }, error, constraints || {});
    });

    api.createAnswer = deferMethod(function (success, error, constraints) {
      OTPlugin.debug('createAnswer', constraints);
      plugin._.createAnswer(id, function(type, sdp) {
        success(new OTPlugin.RTCSessionDescription({
          type: type,
          sdp: sdp
        }));
      }, error, constraints || {});
    });

    api.setLocalDescription = deferMethod( function (description, success, error) {
      OTPlugin.debug('setLocalDescription');

      plugin._.setLocalDescription(id, description, function() {
        hasLocalDescription = true;

        if (hasRemoteDescription) processPendingCandidates();
        if (success) success.call(null);
      }, error);
    });

    api.setRemoteDescription = deferMethod( function (description, success, error) {
      OTPlugin.debug('setRemoteDescription');

      plugin._.setRemoteDescription(id, description, function() {
        hasRemoteDescription = true;

        if (hasLocalDescription) processPendingCandidates();
        if (success) success.call(null);
      }, error);
    });

    api.addIceCandidate = deferMethod( function (candidate) {
      OTPlugin.debug('addIceCandidate');

      if (hasLocalDescription && hasRemoteDescription) {
        plugin._.addIceCandidate(id, candidate, onAddIceCandidate, onAddIceCandidateFailed);
      }
      else {
        candidates.push(candidate);
      }
    });

    api.addStream = deferMethod( function (stream) {
      var constraints = {};
      plugin._.addStream(id, stream, constraints);
    });

    api.removeStream = deferMethod( function (stream) {
      plugin._.removeStream(id, stream);
    });


    api.getRemoteStreams = function () {
      return $.map(plugin._.getRemoteStreams(id), function(stream) {
        return MediaStream.fromJson(stream, plugin);
      });
    };

    api.getLocalStreams = function () {
      return $.map(plugin._.getLocalStreams(id), function(stream) {
        return MediaStream.fromJson(stream, plugin);
      });
    };

    api.getStreamById = function (streamId) {
      return MediaStream.fromJson(plugin._.getStreamById(id, streamId), plugin);
    };

    api.getStats = deferMethod( function (mediaStreamTrack, success, error) {
      plugin._.getStats(id, mediaStreamTrack || null, curryCallAsync(function(statsReportJson) {
        var report = new RTCStatsReport(JSON.parse(statsReportJson));
        success(report);
      }), error);
    });

    api.close = function () {
      plugin._.destroyPeerConnection(id);
      plugin.removeRef(this);
    };

    api.destroy = function () {
      api.close();
    };

    api.addEventListener = function  (event, handler /* [, useCapture] we ignore this */) {
      if (events[event] === void 0) {
        OTPlugin.error('Could not bind invalid event "' + event + '" to PeerConnection. ' +
                        'The valid event types are:');
        OTPlugin.error('\t' + $.keys(events).join(', '));
        return;
      }

      events[event].push(handler);
    };

    api.removeEventListener = function  (event, handler /* [, useCapture] we ignore this */) {
      if (events[event] === void 0) {
        OTPlugin.error('Could not unbind invalid event "' + event + '" to PeerConnection. ' +
                        'The valid event types are:');
        OTPlugin.error('\t' + $.keys(events).join(', '));
        return;
      }

      events[event] = $.filter(events[event], handler);
    };

    // These should appear to be null, instead of undefined, if no
    // callbacks are assigned. This more closely matches how the native
    // objects appear and allows 'if (pc.onsignalingstatechange)' type
    // feature detection to work.
    api.onaddstream = null;
    api.onremovestream = null;
    api.onicecandidate = null;
    api.onsignalingstatechange = null;
    api.oniceconnectionstatechange = null;

    // Both username and credential must exist, otherwise the plugin throws an error
    $.forEach(iceServers.iceServers, function(iceServer) {
      if (!iceServer.username) iceServer.username = '';
      if (!iceServer.credential) iceServer.credential = '';
    });

    if (!plugin._.initPeerConnection(id, iceServers, options)) {
      ready(new $.error('Failed to initialise PeerConnection'));
      return;
    }

    // This will make sense once init becomes async
    bindAndDelegateEvents({
      addStream: addStream,
      removeStream: removeStream,
      iceCandidate: iceCandidate,
      signalingStateChange: signalingStateChange,
      iceConnectionChange: iceConnectionChange
    });

    inited = true;
    processDeferredMethods();
    ready(void 0, api);

    return api;
  }
402172
function JobQueue (job, callback) {
     // ignore null job but notify the queue.
     var device;

    if (job === null) {
         callback (null);
         return;
    }
    
    var gateway = job.gateway;
    var status = 0;
    
    // set few defaults
    if (job.timeout === undefined) job.timeout=0;  // no retry
    if (job.retry   === undefined) job.retry  =0;  // retry counter
    if (job.args    === undefined) job.args   =""; // optional arguments
    
    gateway.Debug (4,"Queue Request=%s DevId=%s Command=%s Retry=%d", job.request, job.devId, job.command, job.retry);
    
    // broadcast command loop on active device list to split commands
    if (parseInt (job.devId) === 0) {
        var subrqst=1;
        for (var devid in gateway.activeClients) {
            // we only broadcast to device with a valid TCP session
            if (device && device.socket !== null) {
                var request = {
                  gateway : job.gateway,
                  devId  : gateway.activeClients[devid].devid,
                  command: job.command,
                  request: [job.request, subrqst++],
                  retry  : job.retry, 
                  timeout: job.timeout
                };
            gateway.queue.push (request, JobCallback); // broadcast to all active devices
            }
        }
        var broadcast = {
            gateway  : job.gateway,
            command : 'Broadcast',
            request : [request, subrqst++]
        };
        callback (broadcast);
        return;
    };
    
    // search for devId withing global active devices list
    if (gateway.activeClients [job.devId] !== undefined) {
        // device is present check if it is logged
        gateway.Debug (5,"Queue Request=%s DevId=%s Command=%s args=%s Sent", job.request, job.devId, job.command, job.args);
        device  = gateway.activeClients [job.devId];
        status  = device.RequestAction (job.command, job.args);
    } else {
        gateway.event.emit ("queue","NOTLOG",job);
        status = 1; // device not present in active list
    }

    // process status result and notify callback function
    switch (status) {
        case 0 : // command was accepted by device
            // wait JOB_QUEUE_PAUSE time before processing Job next request
            gateway.queue.pause ();
            setTimeout(function () {gateway.queue.resume();}, JOB_QUEUE_TIMER);
            gateway.event.emit ("queue", "ACCEPT", job);
            break;
            
        case 1: // device not present command will be retry later  
            if (job.timeout === 0) break;     // no retry
            if (job.timeout >= new Date()) {  // check time out and either push or notify users
                job.retry ++;
                gateway.event.emit ("queue", "RETRY", job);
                setTimeout(function () {gateway.queue.push (job, JobCallback);}, JOB_RETRY_TIMER);
            } else {
                gateway.event.emit ("queue", "TIMEOUT", job);
            }                
            break;
               
        case -1 : // device exits but command was refused
            gateway.event.emit ("queue", "REFUSED", job);
            break;
            
        case -2 : // device does not exist in active device list
            gateway.event.emit ("queue", "UNKNOWN", job);
            break;
               
        default:
            gateway.Debug (2,"Hoops invalid status code: Device DevId=%s Status=%s", job.devId, status);
            break;
    }
    callback (job);
}
914312
function saveResource(callback) {
  var self = this;
  self._applyCustomDataUpdatesIfNecessary(function () {
    self.dataStore.saveResource(self, callback);
  });
}
303705
private void setLastReadDate(Peer peer, long date) {
        storage.put(peer.getUnuqueId(), new ReadState(date).toByteArray());
        readStates.put(peer, date);
    }
814266
def insertInitialPeer(dataRepository, url, logger=None):
    
    insertPeer = dataRepository.insertPeer
    try:
        peer = datamodel.peers.Peer(url)
        insertPeer(peer)
    except exceptions.RepoManagerException as exc:
        if logger:
            logger.debug(
                "Peer already in registry {} {}".format(peer.getUrl(), exc))
    except exceptions.BadUrlException as exc:
        if logger:
            logger.debug("A URL in the initial "
                         "peer list {} was malformed. {}".format(url), exc)
830306
protected void writeParamsToRegistryService(SessionProvider sessionProvider) throws IOException, SAXException,
      ParserConfigurationException, RepositoryException
   {
      if (LOG.isDebugEnabled())
      {
         LOG.debug(">>> Save init parametrs in registry service.");
      }

      Document doc;
      try
      {
         doc = SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Document>()
         {
            public Document run() throws ParserConfigurationException
            {
               return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
            }
         });
      }
      catch (PrivilegedActionException e)
      {
         throw (ParserConfigurationException)e.getCause();
      }

      Element root = doc.createElement(SERVICE_NAME);
      doc.appendChild(root);

      Element element = doc.createElement("nodeType");
      setAttributeSmart(element, "value", getNodeType());
      root.appendChild(element);

      StringBuffer sb = new StringBuffer();
      for (String workspace : observationListenerConfiguration.getWorkspaces())
      {
         if (sb.length() > 0)
         {
            sb.append(';');
         }
         sb.append(workspace);
      }
      element = doc.createElement("workspaces");
      setAttributeSmart(element, "value", sb.toString());
      root.appendChild(element);

      element = doc.createElement("repository");
      setAttributeSmart(element, "value", observationListenerConfiguration.getRepository());
      root.appendChild(element);

      RegistryEntry serviceEntry = new RegistryEntry(doc);
      registryService.createEntry(sessionProvider, RegistryService.EXO_SERVICES, serviceEntry);
   }
919904
function _dispatchServiceResponse({ node, type, status, callerId }, json) {
    const isMultiNode = Array.isArray(node);
    const data = isMultiNode ? json : { [node]: json };
    const postStatus = { name: status, isLoading: false };
    let newStatus = {};
    if (isMultiNode) {
        node.forEach((nd) => { newStatus[nd] = postStatus; });
    } else {
        newStatus[node] = postStatus;
    }
    dispatcher.handleServerAction({
        data,
        type,
        status: newStatus,
        callerId
    });

    // Update information similar to store::afterChange
    return {
        properties: Object.keys(data),
        data,
        status: newStatus,
        informations: { callerId }
    };
}
385714
function (store, type, fixtureRecord) {
    var fixture, fixturesArray;
    if (fixtureRecord.id) {
      fixture = this.fixtureForId(store, type, fixtureRecord.id);
      if (fixture) {
        fixturesArray = this.fixturesForType(store, type);
        fixturesArray.splice(fixturesArray.indexOf(fixtureRecord), 1);
      }
    }
    else {
      throw new Error('Deleting a fixture requires an ID.');
    }
    return null;
  }
1310714
function(store, type, snapshot) {
        var data = this._serializeData(store, type, snapshot);

        return this.ajax(this.buildURL(type.modelName), 'POST', {
          data: data
        });
      }
1143648
function createStore(storeObj) {
    switch(storeObj.type) {
      case 'redis':
        return RedisStore(thorin, storeObj, opt);
      case 'sql':
        return SqlStore(thorin, storeObj, opt);
      case 'file':
        return FileStore(thorin, storeObj.path, opt);
      case 'memory':
        return MemStore(thorin, opt);
      default:
        throw thorin.error('PLUGIN_SESSION', `Invalid session store ${storeObj.type} for the session plugin.`);
    }
  }
323507
function (property, store) {

      if (!isStore(store)) {
        throw new Error('Store expected');
      }

      var _this = this;

      store.onChange(function () {
        if (property) {
          _this.setState(property, store.state);
        } else {
          _this.setState(store.state);
        }
      });

      this.onReset(function () {
        store.resetState();
      });

      this.on('storeWillMount', function () {
        store.replaceProps(_this.props);
        store.emit('storeWillMount');
      });

      this.on('storeWillUnmount', function () {
        store.emit('storeWillUnmount');
        store.replaceProps(_this.props);
      });

      this.on('storeWillReceiveProps', function () {
        store.replaceProps(_this.props);
        store.emit('storeWillReceiveProps');
      });
    }
419748
function get(id, store) {
      var data = store.rootData.asObject();
      // Get item from data object
      return data[id]
        ? data[id]
        : vcomet.error.log("store", "Item with id " + id + " not found");
    }
201712
function(req, res) {
            var store = onmStoreDictionary[req.query.store];
            if ((store == null) || !store) {
                res.send(404, "Data store '" + req.query.store + "' does not exist.");
            } else {
                var addressHash = req.query.address || store.model.jsonTag;
                address = undefined
                try {
                    address = store.model.createAddressFromHashString(addressHash);
                    var namespace = store.openNamespace(address);
            
                    var addresses = [];

                    var processNamespace = function (address_) {
                        addresses.push(address_.getHashString());
                        var model = address_.getModel();
                        if (model.namespaceType === "extensionPoint") {
                            var namespace = store.openNamespace(address_);
                            namespace.visitExtensionPointSubcomponents( function(address_) {
                                processNamespace(address_);
                            });
                        } else {
                            address_.visitChildAddresses( function(address_) {
                                processNamespace(address_);
                            });
                        }
                    };

                    processNamespace(address);
                    var result = {};
                    result[req.query.store] = addresses;
                    res.send(200, result);
                } catch (exception) {
                    res.send(412, exception);
                }
           }
        }
682635
def insertDatastore(self, index, store):
    ''''''
    if not isinstance(store, Datastore):
      raise TypeError("stores must be of type %s" % Datastore)

    self._stores.insert(index, store)