Record operation for sync ops time

@param dest Destination of the socket to connect to. Will actually record
if null. Otherwise will call this on self and corresponding child
with this param null.
@param opTimeUs The number of us for the op to finish
972163
public void recordSyncOpTimeNs(SocketDestination dest, long opTimeNs) {
        if(dest != null) {
            getOrCreateNodeStats(dest).recordSyncOpTimeNs(null, opTimeNs);
            recordSyncOpTimeNs(null, opTimeNs);
        } else {
            this.syncOpTimeRequestCounter.addRequest(opTimeNs);
        }
    }
1133652
function Connection(opts) {

    EventEmitter.call(this);

    opts = opts || {};

    _.defaults(opts, {
        host: 'localhost',
        port: '11211',
        reconnect: true,
        maxValueSize: 1048576
    });

    this.host = opts.host;
    this.port = opts.port;

    this.commandBuffer = new Immutable.List();

    if (opts.onConnect) {
        this.onConnect = opts.onConnect;
    }

    if (opts.onError) {
        this.onError = opts.onError;
    } else {
        this.onError = function onError(err) { this.emit('error'); console.error(err); };
    }
    this.bufferBeforeError = opts.bufferBeforeError;
    this.netTimeout = opts.netTimeout || 500;
    this.backoffLimit = opts.backoffLimit || 10000;
    this.reconnect = opts.reconnect;
    this.disconnecting = false;
    this.ready = false;
    this.backoff = opts.backoff || 10;
    this.maxValueSize = opts.maxValueSize;
    this.writeBuffer = new Immutable.List();

    this.connect();
}
1119667
private void recordSocketCreation(SocketDestination dest, Socket socket) throws SocketException {
        int numCreated = created.incrementAndGet();
        logger.debug("Created socket " + numCreated + " for " + dest.getHost() + ":"
                     + dest.getPort() + " using protocol " + dest.getRequestFormatType().getCode());

        // check buffer sizes--you often don't get out what you put in!
        int sendBufferSize = socket.getSendBufferSize();
        int receiveBufferSize = socket.getReceiveBufferSize();
        if(receiveBufferSize != this.socketBufferSize)
            logger.debug("Requested socket receive buffer size was " + this.socketBufferSize
                         + " bytes but actual size is " + receiveBufferSize + " bytes.");
        if(sendBufferSize != this.socketBufferSize)
            logger.debug("Requested socket send buffer size was " + this.socketBufferSize
                         + " bytes but actual size is " + sendBufferSize + " bytes.");
    }
756915
function GodSocket(opts) {
	var self = this
	events.EventEmitter.call(this)
	this.send = send
	var socketManager = socketio.listen(opts.app)
	var log = opts.log || console.log

	socketManager.set('log level', 0)
	socketManager.sockets.on('connection', newConnection)
	opts = null

	function newConnection(socket) {
		var actionsAreAllowed = getWriteAllowed(socket)

		socket.on('togod', receiveAction)
			//.on('disconnect', 'reason')
			.on('error', socketErrorListener)

		function receiveAction(data) {
			if (actionsAreAllowed) self.emit('data', data, socketSend)
			else {
				log('Denined request:', data)
				socketSend({error: 'denied'})
			}
		}
		function socketErrorListener(etext) {
			log('socket error:', etext)
		}
		function socketSend(data) {
			socket.emit('fromgod', data)
		}
	}

	function send(update) {
		socketManager.sockets.emit('fromgod', update) // emit has no callback
	}

	function getWriteAllowed(socket) {
		// determine if writing is allowed for this socket
		// ie. from localhost
		var ip
		var sockid = socket.id
		if (sockid) {
			var hand = socket.manager && socket.manager.handshaken &&
				socket.manager.handshaken
			if (hand && hand[sockid] && hand[sockid].address) ip = hand[sockid].address.address
			log('Connecting ip:', ip)
		}
		return ip === '127.0.0.1'
	}
}
971510
function (destCtx, debug) {
                if (!this.visible) {
                    return;
                }

                // auto goto next frame
                if (this.currentAnimName.length) {
                    this.advanceFrame(this.currentAnimName);
                }

                var w = this.getCurrentWidth(),
                    scaledW = w * this.scale,
                    h = this.getCurrentHeight(),
                    scaledH = h * this.scale,
                    subScaledW = (scaledW / 2) | 0,
                    subScaledH = (scaledH / 2) | 0,
                    x = this.getCurrentOffsetX(),
                    y = this.getCurrentOffsetY(),
                    drawX = this.x + this.getCurrentShiftX(),
                    drawY = this.y + this.getCurrentShiftY(),
                    mapOffsetX = this.currentMap && this.currentMap.viewportX || 0,

                    mapOffsetY = this.currentMap && this.currentMap.viewportY || 0;

                // TODO: fix map position when rotate is used
                if ($.isEmptyObject(this.fxQueue)) {
                    if (this.type === 'enemy1' && window.todo)
                        var date = new Date().getTime();
                    destCtx.drawImage(this.image, x, y, w, h, drawX + mapOffsetX, drawY + mapOffsetY, scaledW, scaledH);
                    if (this.type === 'enemy1' && window.todo) {
                        var date2 = new Date().getTime();
                        console.log('drawSprite call duration:', date2 - date);
                    }
                    if (this.isDebug === true || debug === true) {
                        this.showHitBox(destCtx);
                    }
                } else {
                    this.executeFx(destCtx);
                    // translate to keep the object as its position
                    destCtx.save();
                    destCtx.translate(drawX + mapOffsetX + subScaledW, drawY + mapOffsetY + subScaledH);
                    destCtx.rotate(this.angle);
                    destCtx.drawImage(this.image, x, y, w, h, -subScaledW, -subScaledH, scaledW, scaledH);
                    if (this.isDebug === true || debug === true) {
                        this.showHitBox(destCtx);
                    }
                    destCtx.restore();
                }
            }
1159935
public GrpcServerBuilder keepAliveTime(long keepAliveTime, TimeUnit timeUnit) {
    mNettyServerBuilder = mNettyServerBuilder.keepAliveTime(keepAliveTime, timeUnit);
    return this;
  }
602004
@Deprecated
    @Override
    public void getOffsetFromLocal(long date,
            int nonExistingTimeOpt, int duplicatedTimeOpt, int[] offsets) {
        tz.getOffsetFromLocal(date, nonExistingTimeOpt, duplicatedTimeOpt, offsets);
    }
518503
void recordOperationPrepareTimeout(final BlockingQueueOperationListener.FailedOperation<ServerOperation> failedOperation) {
        recordPreparedTask(new ServerTaskExecutor.ServerPreparedResponse(failedOperation));
        // Swap out the submitted task so we don't wait for the final result. Use a future the returns
        // prepared response
        ServerIdentity identity = failedOperation.getOperation().getIdentity();
        AsyncFuture<OperationResponse> finalResult = failedOperation.getFinalResult();
        synchronized (submittedTasks) {
            submittedTasks.put(identity, new ServerTaskExecutor.ExecutedServerRequest(identity, finalResult));
        }
    }
1211538
function(opts) {
  opts = opts || {};
  this._context = opts.context;
  this._routeContext = opts.routeContext;
  this.router = opts.router || router.df;
  this.routerType = opts.routerType;
  this.rpcDebugLog = opts.rpcDebugLog;
  if (this._context) {
    opts.clientId = this._context.serverId;
  }
  this.opts = opts;
  this.proxies = {};
  this._station = createStation(opts);
  this.state = STATE_INITED;
}
282689
function Blink (opts) {
    Blink.superclass.constructor.call(this, opts)
    this.times = opts.blinks
}
1334522
public void sync() throws IOException {
  	long start = System.currentTimeMillis();
    try {
      long toWaitFor;
      synchronized (this) {
        eventStartSync();
        /* Record current blockOffset. This might be changed inside
         * flushBuffer() where a partial checksum chunk might be flushed.
         * After the flush, reset the bytesCurBlock back to its previous value,
         * any partial checksum chunk will be sent now and in next packet.
         */
        long saveOffset = bytesCurBlock;
        DFSOutputStreamPacket oldCurrentPacket = currentPacket;

        // flush checksum buffer as an incomplete chunk
        flushBuffer(false, shouldKeepPartialChunkData());
        // bytesCurBlock potentially incremented if there was buffered data
        
        eventSyncStartWaitAck();
        
        if (DFSClient.LOG.isDebugEnabled()) {
          DFSClient.LOG.debug("DFSClient flush() : bytesCurBlock " + bytesCurBlock +
                    " lastFlushOffset " + lastFlushOffset);
        }

        // Flush only if we haven't already flushed till this offset.
        if (lastFlushOffset != bytesCurBlock) {
          assert bytesCurBlock > lastFlushOffset;
          // record the valid offset of this flush
          lastFlushOffset = bytesCurBlock;
          enqueueCurrentPacket();
        } else {
          // just discard the current packet since it is already been sent.
          if (oldCurrentPacket == null && currentPacket != null) {
            // If we didn't previously have a packet queued, and now we do,
            // but we don't plan on sending it, then we should not
            // skip a sequence number for it!
            currentSeqno--;
          }
          currentPacket = null;
        }

        if (shouldKeepPartialChunkData()) {
          // Restore state of stream. Record the last flush offset
          // of the last full chunk that was flushed.
          //
          bytesCurBlock = saveOffset;
        }
        toWaitFor = lastQueuedSeqno;
      }

      waitForAckedSeqno(toWaitFor);
      
      eventSyncPktAcked();

      // If any new blocks were allocated since the last flush,
      // then persist block locations on namenode.
      //
      boolean willPersist;
      synchronized (this) {
        willPersist = persistBlocks;
        persistBlocks = false;
      }
      if (willPersist) {
        dfsClient.namenode.fsync(src, dfsClient.clientName);
      }
      long timeval = System.currentTimeMillis() - start;
      dfsClient.metrics.incSyncTime(timeval);

      eventEndSync();

    } catch (IOException e) {
        lastException = new IOException("IOException flush:", e);
        closed = true;
        closeThreads();
        throw e;
    }
  }
172309
function synchronize() {
    if (syncPointer != -1) {
        log.logMessage("verbose", "redis synchronization!");
        var syncMessage = {};
        syncMessage.data = messages.splice(syncPointer, messages.length - syncPointer);
        setTimeout(function () {
            pub.publish("message", JSON.stringify(syncMessage));
        }, 200);
        syncPointer = -1;
    }
}
164434
synchronized void sync()
    {
        try
        {
            // check we have more work to do
            if (allocatePosition.get() <= lastSyncedOffset + SYNC_MARKER_SIZE)
                return;

            // allocate a new sync marker; this is both necessary in itself, but also serves to demarcate
            // the point at which we can safely consider records to have been completely written to
            int nextMarker;
            nextMarker = allocate(SYNC_MARKER_SIZE);
            boolean close = false;
            if (nextMarker < 0)
            {
                // ensure no more of this CLS is writeable, and mark ourselves for closing
                discardUnusedTail();
                close = true;

                // wait for modifications guards both discardedTailFrom, and any outstanding appends
                waitForModifications();

                if (discardedTailFrom < buffer.capacity() - SYNC_MARKER_SIZE)
                {
                    // if there's room in the discard section to write an empty header, use that as the nextMarker
                    nextMarker = discardedTailFrom;
                }
                else
                {
                    // not enough space left in the buffer, so mark the next sync marker as the EOF position
                    nextMarker = buffer.capacity();
                }
            }
            else
            {
                waitForModifications();
            }

            assert nextMarker > lastSyncedOffset;

            // write previous sync marker to point to next sync marker
            // we don't chain the crcs here to ensure this method is idempotent if it fails
            int offset = lastSyncedOffset;
            final PureJavaCrc32 crc = new PureJavaCrc32();
            crc.updateInt((int) (id & 0xFFFFFFFFL));
            crc.updateInt((int) (id >>> 32));
            crc.updateInt(offset);
            buffer.putInt(offset, nextMarker);
            buffer.putInt(offset + 4, crc.getCrc());

            // zero out the next sync marker so replayer can cleanly exit
            if (nextMarker < buffer.capacity())
            {
                buffer.putInt(nextMarker, 0);
                buffer.putInt(nextMarker + 4, 0);
            }

            // actually perform the sync and signal those waiting for it
            buffer.force();

            if (close)
                nextMarker = buffer.capacity();

            lastSyncedOffset = nextMarker;
            syncComplete.signalAll();

            CLibrary.trySkipCache(fd, offset, nextMarker);
            if (close)
                internalClose();
        }
        catch (Exception e) // MappedByteBuffer.force() does not declare IOException but can actually throw it
        {
            throw new FSWriteError(e, getPath());
        }
    }
548554
public void getPersistentData(ObjectOutputStream dout)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getPersistentData", dout);

    try
    {
      dout.writeUTF(remoteMEId.toString()); 
      dout.writeUTF(streamId.toString());
      String id = NULL;
      if (gatheringTargetDestUuid!=null) 
        id = gatheringTargetDestUuid.toString();
      dout.writeUTF(id); 
    }
    catch (IOException e)
    {
      // No FFDC code needed
      SIErrorException e2 = new SIErrorException(e);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "getPersistentData", e2);

      throw e2;
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getPersistentData");
  }
1059209
@Override
    public boolean isCallTimedOut(Operation op) {
        // Join and WAN replication operations should not be checked for timeout
        // because caller is not member of this cluster and can have a different
        // clock.
        if (isJoinOperation(op) || isWanReplicationOperation(op)) {
            return false;
        }

        long callTimeout = op.getCallTimeout();
        long invocationTime = op.getInvocationTime();
        long expireTime = invocationTime + callTimeout;

        if (expireTime <= 0 || expireTime == Long.MAX_VALUE) {
            return false;
        }

        ClusterClock clusterClock = nodeEngine.getClusterService().getClusterClock();
        long now = clusterClock.getClusterTime();
        if (expireTime < now) {
            return true;
        }

        return false;
    }
843841
public static void traceCommon(int opType, String txId, String desc)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
        {
            StringBuffer sbuf = new StringBuffer();

            sbuf
                            .append(TxLifeCycle_State_Type_Str).append(DataDelimiter)
                            .append(TxLifeCycle_State_Type).append(DataDelimiter)
                            .append(opType).append(DataDelimiter)
                            .append(txId).append(DataDelimiter)
                            .append(desc);

            Tr.debug(tc, sbuf.toString());
        }
    }
11308
function updateStatus(evType, opts) {
    var t2 = new Date()
    var elapsed = (t2.getTime() - t1.getTime()) / 1000
    var msg = {
      timeElapsed:elapsed,
      stdout: opts.stdout || "",
      stderr: opts.stderr || "",
      stdmerged: opts.stdmerged || "",
      info: opts.info,
      step: opts.step,
      deployExitCode: null,
      url: null || opts.url,
    }
    if (opts.deployExitCode !== undefined) {
      msg.deployExitCode = opts.deployExitCode
    }

    emitter.emit(evType, msg)
  }