sync by creating nodes in external layers when needed
187515
def save_external_nodes(sender, **kwargs):
    
    node = kwargs['instance']
    operation = 'add' if kwargs['created'] is True else 'change'

    if node.layer.is_external is False or not hasattr(node.layer, 'external') or node.layer.external.synchronizer_path is None:
        return False

    push_changes_to_external_layers.delay(node=node, external_layer=node.layer.external, operation=operation)
871180
def add(self, *tasks):
        
        nodes = [x.node for x in tasks]
        self.node.add(*nodes)
        return self
545137
def sync_sources(self, force=False):
        """"""
        from ambry.orm.file import File

        self.dstate = self.STATES.BUILDING

        synced = 0

        for fc in [File.BSFILE.SOURCES]:
            bsf = self.build_source_files.file(fc)
            if bsf.fs_is_newer or force:
                self.log('Syncing {}'.format(bsf.file_name))
                bsf.fs_to_objects()
                synced += 1

        return synced
1320668
function connect(orbs, callback) {
  var total = Object.keys(orbs).length,
      finished = 0;

  function done() {
    finished++;
    if (finished >= total) { callback(); }
  }

  for (var name in orbs) {
    orbs[name].connect(done);
  }
}
740321
def sync(self, bForce):
        """"""

        fn = self.function_table.sync
        peError = EVRSettingsError()
        result = fn(bForce, byref(peError))
        return result, peError
53286
function(callback) {
        var self = this;

        this.loadbalancer.updateNode(self, function(err, nodes) {
            if (err) {
                callback(err);
                return;
            }

            nodes.forEach(function(node) {
                if (node.id == self.id) {
                    self = node;
                }
            });

            callback(err);
        });
    }
49308
def sync(self):
        """"""
        for i in range(4):
            self.elk.send(ps_encode(i))
        self.get_descriptions(TextDescriptions.LIGHT.value)
204715
def sync(func):
    """"""
    sync_timeout = 3600  # Match standard synchronous timeout.

    def wraps(*args, **kwargs):
        task = func(*args, **kwargs)
        task.wait_for_result(timeout=sync_timeout)
        result = json.loads(task.result)
        return result

    return wraps
342024
void build(int nodeOffset, GraphMeshData graphData, List<int[]> connections) {
		for (int n = 0; n < connections.size(); n++) {
			int[] nodeConnections = connections.get(n);
			MeshData tile = graphData.getTile(n);
			Poly node = graphData.getNode(n);
			for (int connection : nodeConnections) {
				MeshData neighbourTile = graphData.getTile(connection - nodeOffset);
				if (neighbourTile != tile) {
					buildExternalLink(tile, node, neighbourTile);
				} else {
					Poly neighbour = graphData.getNode(connection - nodeOffset);
					buildInternalLink(tile, node, neighbourTile, neighbour);
				}
			}
		}
	}
1299382
def delete_external_nodes(sender, **kwargs):
    
    node = kwargs['instance']

    if node.layer.is_external is False or not hasattr(node.layer, 'external') or node.layer.external.synchronizer_path is None:
        return False

    if hasattr(node, 'external') and node.external.external_id:
        push_changes_to_external_layers.delay(
            node=node.external.external_id,
            external_layer=node.layer.external,
            operation='delete'
        )
1187368
def sync(self):
        """"""
        self.elk.send(cp_encode())
        self.get_descriptions(TextDescriptions.SETTING.value)
18416
public void sync() {

        if (isClosed) {
            return;
        }

        synchronized (fileStreamOut) {
            if (needsSync) {
                if (busyWriting) {
                    forceSync = true;

                    return;
                }

                try {
                    fileStreamOut.flush();
                    outDescriptor.sync();

                    syncCount++;
                } catch (IOException e) {
                    Error.printSystemOut("flush() or sync() error: "
                                         + e.toString());
                }

                needsSync = false;
                forceSync = false;
            }
        }
    }
1081903
function(callback) {
    //process first all directories and then all files.
    async.mapSeries(['getDirectories', 'getFiles'], (nodeSource, cbMap) => {
      syncDb[nodeSource]((err, nodes) => {
        async.eachSeries(nodes, (node, cb) => {
          if(node.localActions && node.localActions.create) {
            var nodePath = utility.joinPath(node.parent, node.name);

            syncDb.findByPath(nodePath, (err, syncedNode) => {
              try {
                var stat = fsWrap.lstatSync(nodePath);
              } catch(e) {
                logger.warning('resolveConflicts got lstat error on node', {category: 'sync-local-delta', nodePath, code: e.code});
                throw new BlnDeltaError(e.message);
              }

              //deleted and recreated at same path
              if(syncedNode.localActions && syncedNode.localActions.delete) {
                syncedNode.ino = stat.ino;

                delete syncedNode.localActions.delete;

                if(syncedNode.directory) {
                  syncedNode.ctime = stat.ctime;
                  syncedNode.mtime = stat.mtime;
                  syncedNode.size = stat.size;
                } else {
                  syncedNode.localActions.create = node.localActions.create;
                }

                async.parallel([
                  (cbParallel) => {
                    syncDb.update(syncedNode._id, syncedNode, cbParallel);
                  },
                  (cbParallel) => {
                    syncDb.remove(node._id, cbParallel);
                  }
                ], cb);
              } else {
                cb(null);
              }
            });
          } else {
            cb(null);
          }
        }, cbMap);
      });
    }, callback);
  }
1066253
private <T, S extends ISyncableData> void doSync(T caller, String... syncNames)
	{
		@SuppressWarnings("unchecked")
		ISyncHandler<T, S> handler = (ISyncHandler<T, S>) getHandler(caller);
		if (handler == null)
			return;

		S data = handler.getSyncData(caller);
		int indexes = getFieldIndexes(handler, syncNames);
		Map<String, Object> values = getFieldValues(caller, handler, syncNames);

		SyncerMessage.Packet<T, S> packet = new Packet<>(getHandlerId(caller.getClass()), data, indexes, values);

		handler.send(caller, packet);
	}
749643
function updateSync(newData, newParent, newIdx, withDOM, withRedraw) {
	var vm = this;

	if (newData != null) {
		if (vm.data !== newData) {
			{
				devNotify("DATA_REPLACED", [vm, vm.data, newData]);
			}
			fireHook(vm.hooks, "willUpdate", vm, newData);
			vm.data = newData;
		}
	}

	return withRedraw ? vm._redraw(newParent, newIdx, withDOM) : vm;
}
913122
function Node (config) {
    RED.nodes.createNode(this, config);
    var node = this;

    // Invoked when the node has received an input as part of a flow.
    this.on('input', function (msg) {
      processOnInput(msg, config, node);
    });
  }
107854
def add_nodes(self, new_nodes):
        """"""
        for unique_id, node in new_nodes.items():
            if unique_id in self.nodes:
                raise_duplicate_resource_name(node, self.nodes[unique_id])
            self.nodes[unique_id] = node