Loop over entries in the slop table and attempt to push them to the
deserving server
549395
public void run() {

        // don't try to run slop pusher job when rebalancing
        if(metadataStore.getServerStateUnlocked()
                        .equals(MetadataStore.VoldemortState.REBALANCING_MASTER_SERVER)) {
            logger.error("Cannot run slop pusher job since Voldemort server is rebalancing");
            return;
        }

        logger.info("Started blocking slop pusher job at " + new Date());

        Cluster cluster = metadataStore.getCluster();
        failureDetector.getConfig().setCluster(cluster);
        Set<String> storeNames = StoreDefinitionUtils.getStoreNamesSet(metadataStore.getStoreDefList());

        ClosableIterator<Pair<ByteArray, Versioned<Slop>>> iterator = null;

        Map<Integer, Long> attemptedByNode = Maps.newHashMapWithExpectedSize(cluster.getNumberOfNodes());
        Map<Integer, Long> succeededByNode = Maps.newHashMapWithExpectedSize(cluster.getNumberOfNodes());
        long slopsPushed = 0L;
        long attemptedPushes = 0L;
        for(Node node: cluster.getNodes()) {
            attemptedByNode.put(node.getId(), 0L);
            succeededByNode.put(node.getId(), 0L);
        }

        acquireRepairPermit();
        try {
            SlopStorageEngine slopStorageEngine = storeRepo.getSlopStore();
            StorageEngine<ByteArray, Slop, byte[]> slopStore = slopStorageEngine.asSlopStore();
            EventThrottler throttler = new EventThrottler(maxWriteBytesPerSec);

            iterator = slopStore.entries();

            while(iterator.hasNext()) {
                if(Thread.interrupted())
                    throw new InterruptedException("Slop pusher job cancelled");

                try {
                    Pair<ByteArray, Versioned<Slop>> keyAndVal;
                    try {
                        keyAndVal = iterator.next();
                    } catch(Exception e) {
                        logger.error("Exception in iterator, escaping the loop ", e);
                        break;
                    }

                    Versioned<Slop> versioned = keyAndVal.getSecond();
                    Slop slop = versioned.getValue();
                    int nodeId = slop.getNodeId();

                    // check for dead slops
                    if(isSlopDead(cluster, storeNames, versioned.getValue())) {
                        handleDeadSlop(slopStorageEngine, keyAndVal);
                        // No matter we deleted it or not, we need to move onto
                        // the next slop.
                        continue;
                    }

                    Node node = cluster.getNodeById(nodeId);

                    attemptedPushes++;
                    if(attemptedPushes % 10000 == 0) {
                        logger.info("Attempted pushing " + attemptedPushes + " slops");
                    }
                    Long attempted = attemptedByNode.get(nodeId);
                    attemptedByNode.put(nodeId, attempted + 1L);

                    if(failureDetector.isAvailable(node)) {
                        Store<ByteArray, byte[], byte[]> store = storeRepo.getNodeStore(slop.getStoreName(),
                                                                                        node.getId());
                        Long startNs = System.nanoTime();
                        int nBytes = 0;
                        try {
                            nBytes = slop.getKey().length();
                            if(slop.getOperation() == Operation.PUT) {
                                store.put(slop.getKey(),
                                          new Versioned<byte[]>(slop.getValue(),
                                                                versioned.getVersion()),
                                          slop.getTransforms());
                                nBytes += slop.getValue().length
                                          + ((VectorClock) versioned.getVersion()).sizeInBytes()
                                          + 1;

                            } else if(slop.getOperation() == Operation.DELETE) {
                                nBytes += ((VectorClock) versioned.getVersion()).sizeInBytes() + 1;
                                store.delete(slop.getKey(), versioned.getVersion());
                            } else {
                                logger.error("Unknown slop operation: " + slop.getOperation());
                                continue;
                            }
                            failureDetector.recordSuccess(node, deltaMs(startNs));
                            slopStore.delete(slop.makeKey(), versioned.getVersion());

                            slopsPushed++;
                            // Increment succeeded
                            Long succeeded = succeededByNode.get(nodeId);
                            succeededByNode.put(nodeId, succeeded + 1L);

                            // Throttle the bytes...
                            throttler.maybeThrottle(nBytes);

                        } catch(ObsoleteVersionException e) {

                            // okay it is old, just delete it
                            slopStore.delete(slop.makeKey(), versioned.getVersion());
                            slopsPushed++;

                            // Increment succeeded
                            Long succeeded = succeededByNode.get(nodeId);
                            succeededByNode.put(nodeId, succeeded + 1L);

                            // Throttle the bytes...
                            throttler.maybeThrottle(nBytes);

                        } catch(UnreachableStoreException e) {
                            failureDetector.recordException(node, deltaMs(startNs), e);
                        }
                    }
                } catch(Exception e) {
                    logger.error(e, e);
                }
            }

            // Only if we reached here do we update stats
            logger.log(attemptedPushes > 0 ? Level.INFO : Level.DEBUG,
                       "Attempted " + attemptedPushes + " hinted handoff pushes of which "
                               + slopsPushed + " succeeded.");

            Map<Integer, Long> outstanding = Maps.newHashMapWithExpectedSize(cluster.getNumberOfNodes());
            for(int nodeId: succeededByNode.keySet()) {
                outstanding.put(nodeId, attemptedByNode.get(nodeId) - succeededByNode.get(nodeId));
            }

            slopStorageEngine.resetStats(outstanding);

        } catch(Exception e) {
            logger.error(e, e);
        } finally {
            try {
                if(iterator != null)
                    iterator.close();
            } catch(Exception e) {
                logger.error("Failed to close iterator.", e);
            }
            this.repairPermits.release(this.getClass().getCanonicalName());
        }
    }
670973
def do_rmall(self, line):
        ""
        args = self.getargs(line)
        if args and args[-1] == "yes":
            args.pop()

            if not args:
                args = [self.table.table_name]

            while args:
                table = boto.dynamodb2.table.Table(args.pop(0), connection=self.conn)
                print "from table " + table.table_name

                for item in table.scan(attributes_to_get=[], request_limit=10):
                    print "  removing %s" % item
                    item.delete()
        else:
            print "ok, never mind..."
206250
function (table, index, obj) {
			if (!((table || shine.EMPTY_OBJ) instanceof shine.Table)) throw new shine.Error('Bad argument #1 in table.insert(). Table expected');
	
			if (obj == undefined) {
				obj = index;
				index = table.__shine.numValues.length;
			} else {
				index = shine.utils.coerceToNumber(index, "Bad argument #2 to 'insert' (number expected)");
			}
	
			table.__shine.numValues.splice(index, 0, undefined);
			table.setMember(index, obj);
		}
904778
def wait_until_table_is_available(full_table_name, delay = 5, max_attempts = 5)
      puts "Waiting for Table #{full_table_name} to be available."
      puts "Waiting with a #{delay} second delay between attempts, for a maximum of #{max_attempts} attempts."
      max_time = Time.at(delay * max_attempts).utc.strftime('%H:%M:%S')
      puts "Max waiting time will be: #{max_time} (approximate)."
      # wait until the table has updated to being fully available
      # waiting for ~2min at most; an error will be thrown afterwards

      started_waiting_at = Time.now
      max_attempts.times do |attempt|
        puts "Attempt #{attempt + 1}/#{max_attempts}, \
        #{Time.at(Time.now - started_waiting_at).utc.strftime('%H:%M:%S')}/#{max_time}"

        details = retrieve_table_details(full_table_name)

        if details.table_status != 'ACTIVE'
          puts "Table: #{full_table_name} is not yet available. Status: #{details.table_status}. Retrying..."
        else
          updating_indexes = details.global_secondary_indexes.reject do |global_index|
            global_index.index_status == 'ACTIVE'
          end
          return true if updating_indexes.empty?
          puts 'Table is available, but the global indexes are not:'
          puts(updating_indexes.map { |global_index| "#{global_index.index_name}, #{global_index.index_status}" })
        end
        Kernel.sleep(delay.seconds)
      end

      raise Exception, "Table #{full_table_name} did not become available after #{max_attempts} attempts. " \
        'Try again later or inspect the AWS console.'
    end
133543
def push(self):
        """"""
        self._refresh_connection()

        # Check if we need to update mappings as this needs to be done
        # before we push anything to the Elasticsearch server.
        # This must be done even if the queue is empty, as otherwise ES
        # will fail when retrieving data.
        if not self._mapping_created:
            logger.debug("Pushing mapping for Elasticsearch index '%s'.", self.__class__.__name__)
            self.create_mapping()

        if not self.push_queue:
            logger.debug("No documents to push, skipping push.")
            return

        logger.debug("Found %s documents to push to Elasticsearch.", len(self.push_queue))

        bulk(connections.get_connection(), (doc.to_dict(True) for doc in self.push_queue), refresh=True)
        self.push_queue = []

        logger.debug("Finished pushing builded documents to Elasticsearch server.")
506077
def push(self):
        """"""
        print `request.body`
        yield request.environ['cogen.call'](pubsub.publish)(
            "%s: %s" % (session['client'].name, request.body)
        )
        # the request.environ['cogen.*'] objects are the the asynchronous
        # make the code here work as a coroutine and still work with any
        # wsgi extensions offered by cogen - basicaly they do some magic to
        # middleware
        yield str(request.environ['cogen.wsgi'].result)
117163
function processTablesKeys(){
				var tablesKeys = [];

				module.tables.forEach(function(table){
					tablesKeys.push({
						value: table.get('id'),
						text: table.get('name'),
					});
				});

				module.tablesKeys = tablesKeys;
			}
774779
function ClosedBlock_Handle_Loop(&$res)
    {
        if ($res['ArgumentCount'] > 1) {
            throw new SSTemplateParseException('Either no or too many arguments in control block. Must be one ' .
                'argument only.', $this);
        }

        //loop without arguments loops on the current scope
        if ($res['ArgumentCount'] == 0) {
            $on = '$scope->obj(\'Up\', null)->obj(\'Foo\', null)';
        } else {    //loop in the normal way
            $arg = $res['Arguments'][0];
            if ($arg['ArgumentMode'] == 'string') {
                throw new SSTemplateParseException('Control block cant take string as argument.', $this);
            }
            $on = str_replace(
                '$$FINAL',
                'obj',
                ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']
            );
        }

        return
            $on . '; $scope->pushScope(); while (($key = $scope->next()) !== false) {' . PHP_EOL .
                $res['Template']['php'] . PHP_EOL .
            '}; $scope->popScope(); ';
    }
1163343
function runQuery(query, connection) {
  let incomplete = false;
  const rows = [];

  const drillConfig = {
    host: connection.host,
    port: connection.port,
    user: connection.username,
    password: connection.password,
    defaultSchema: connection.drillDefaultSchema,
    ssl: connection.ssl || false
  };
  const client = new drill.Client(drillConfig);

  return client.query(drillConfig, query).then(result => {
    if (!result) {
      throw new Error('No result returned');
    } else if (result.errorMessage && result.errorMessage.length > 0) {
      console.log('Error with query: ' + query);
      console.log(result.errorMessage);
      throw new Error(result.errorMessage.split('\n')[0]);
    }
    if (result.length > connection.maxRows) {
      incomplete = true;
      result['rows'] = result['rows'].slice(0, connection.maxRows);
    }
    for (let r = 0; r < result['rows'].length; r++) {
      const row = {};
      for (let c = 0; c < result['columns'].length; c++) {
        row[result['columns'][c]] = result['rows'][r][result['columns'][c]];
      }
      rows.push(row);
    }
    return { rows, incomplete };
  });
}
1254678
def insert(self, table,items, values):
        
        values = ["'{0}'".format(e) for e in values]
        self._query = "INSERT INTO {0} ({1}) VALUES ({2})".format(table,','.join(items),','.join(values))
        payload = self._payload_builder(self._query)
        response = self.execute_query(payload)

        return response
166883
def insert_index(self, table, name, url, std=""):
        """"""
        names = self.parse_title(name);

        for n in names:
            self.db_cursor.execute(
                'INSERT INTO "%s" (name, url, std) VALUES (?, ?, ?)' % table, (
                n, url, std))
1248066
def attachIterator(self, login, tableName, setting, scopes):
    
    self.send_attachIterator(login, tableName, setting, scopes)
    self.recv_attachIterator()
153050
private void dble() {
            Assert.check(shared == 0);
            Entry[] oldtable = table;
            Entry[] newtable = new Entry[oldtable.length * 2];
            for (ScopeImpl s = this; s != null; s = s.next) {
                if (s.table == oldtable) {
                    Assert.check(s == this || s.shared != 0);
                    s.table = newtable;
                    s.hashMask = newtable.length - 1;
                }
            }
            int n = 0;
            for (int i = oldtable.length; --i >= 0; ) {
                Entry e = oldtable[i];
                if (e != null && e != sentinel) {
                    table[getIndex(e.sym.name)] = e;
                    n++;
                }
            }
            // We don't need to update nelems for shared inherited scopes,
            // since that gets handled by leave().
            nelems = n;
        }
1040629
def insert_request_to_batch(self, request):
        '''
        
        '''
        self.validate_request_table(request)
        self.validate_request_partition_key(request)
        self.validate_request_row_key(request)
        self.batch_requests.append(request)
327721
def push(value)
      RedisEventStore.instance.lpush(@key, value)
    rescue Redis::CommandError, Redis::CannotConnectError
      RedisEventStore.logger.error("unable to push event: #{@key}")
      nil
    end
683594
function pushFrame(resultSet, options, frameElement, frameSelector) {
	'use strict';
	var frameXpath = axe.utils.getXpath(frameElement);
	var frameSpec = {
		element: frameElement,
		selector: frameSelector,
		xpath: frameXpath
	};

	resultSet.forEach(function(res) {
		res.node = axe.utils.DqElement.fromFrame(res.node, options, frameSpec);

		var checks = axe.utils.getAllChecks(res);
		if (checks.length) {
			checks.forEach(function(check) {
				check.relatedNodes = check.relatedNodes.map(node =>
					axe.utils.DqElement.fromFrame(node, options, frameSpec)
				);
			});
		}
	});
}
513504
def insert(table, values=(), **kwargs):
    """"""
    values = dict(values, **kwargs).items()
    sql, args = makeSQL("INSERT", table, values=values)
    return execute(sql, args).lastrowid