/** * Initializes this instance. Installs itself as proxy handler on the * session. * * @param session * to initialize for */ protected void init(ClientSession session) { remainingProxyProtocolTime = session.getLongProperty( StatefulProxyConnector.TIMEOUT_PROPERTY, DEFAULT_PROXY_TIMEOUT_MILLIS); if (remainingProxyProtocolTime <= 0L) { remainingProxyProtocolTime = DEFAULT_PROXY_TIMEOUT_MILLIS; } if (session instanceof JGitClientSession) { JGitClientSession s = (JGitClientSession) session; unregister.set(() -> s.setProxyHandler(null)); s.setProxyHandler(this); } else { // Internal error, no translation throw new IllegalStateException( "Not a JGit session: " + session.getClass().getName()); //$NON-NLS-1$ } }
protected synchronized void startHeartBeat() { stopHeartBeat(); ClientSession session = getClientSession(); long interval = session.getLongProperty(ClientFactoryManager.HEARTBEAT_INTERVAL, ClientFactoryManager.DEFAULT_HEARTBEAT_INTERVAL); if (interval > 0L) { FactoryManager manager = session.getFactoryManager(); ScheduledExecutorService service = manager.getScheduledExecutorService(); heartBeat = service.scheduleAtFixedRate(this::sendHeartBeat, interval, interval, TimeUnit.MILLISECONDS); if (log.isDebugEnabled()) { log.debug("startHeartbeat - started at interval={}", interval); } } }
protected synchronized void startHeartBeat() { stopHeartBeat(); ClientSession session = getClientSession(); long interval = session.getLongProperty(ClientFactoryManager.HEARTBEAT_INTERVAL, ClientFactoryManager.DEFAULT_HEARTBEAT_INTERVAL); if (interval > 0L) { FactoryManager manager = session.getFactoryManager(); ScheduledExecutorService service = manager.getScheduledExecutorService(); heartBeat = service.scheduleAtFixedRate(this::sendHeartBeat, interval, interval, TimeUnit.MILLISECONDS); if (log.isDebugEnabled()) { log.debug("startHeartbeat - started at interval={}", interval); } } }
protected ChannelExec openCommandChannel(ClientSession session, String cmd) throws IOException { long waitTimeout = session.getLongProperty(SCP_EXEC_CHANNEL_OPEN_TIMEOUT, DEFAULT_EXEC_CHANNEL_OPEN_TIMEOUT); ChannelExec channel = session.createExecChannel(cmd); long startTime = System.nanoTime(); try { channel.open().verify(waitTimeout); long endTime = System.nanoTime(); long nanosWait = endTime - startTime; if (log.isTraceEnabled()) { log.trace("openCommandChannel(" + session + ")[" + cmd + "]" + " completed after " + nanosWait + " nanos out of " + TimeUnit.MILLISECONDS.toNanos(waitTimeout)); } return channel; } catch (IOException | RuntimeException e) { long endTime = System.nanoTime(); long nanosWait = endTime - startTime; if (log.isTraceEnabled()) { log.trace("openCommandChannel(" + session + ")[" + cmd + "]" + " failed (" + e.getClass().getSimpleName() + ")" + " to complete after " + nanosWait + " nanos out of " + TimeUnit.MILLISECONDS.toNanos(waitTimeout) + ": " + e.getMessage()); } channel.close(false); throw e; } }
this.channel.setErr(new ByteArrayOutputStream(Byte.MAX_VALUE)); long initializationTimeout = clientSession.getLongProperty(SFTP_CHANNEL_OPEN_TIMEOUT, DEFAULT_CHANNEL_OPEN_TIMEOUT); this.channel.open().verify(initializationTimeout); this.channel.onClose(() -> {