本文整理汇总了Java中org.apache.sshd.common.util.GenericUtils.size方法的典型用法代码示例。如果您正苦于以下问题:Java GenericUtils.size方法的具体用法?Java GenericUtils.size怎么用?Java GenericUtils.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.sshd.common.util.GenericUtils
的用法示例。
在下文中一共展示了GenericUtils.size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.apache.sshd.common.util.GenericUtils; //导入方法依赖的package包/类
@Override
public Command create() {
final SftpSubsystem subsystem = new SftpSubsystem(getExecutorService(), isShutdownOnExit(),
getUnsupportedAttributePolicy()) {
@Override
protected void setFileAttribute(final Path file, final String view, final String attribute,
final Object value, final LinkOption... options) throws IOException {
throw new UnsupportedOperationException("setFileAttribute Disabled");
}
@Override
protected void createLink(final int id, final String targetPath, final String linkPath,
final boolean symLink) throws IOException {
throw new UnsupportedOperationException("createLink Disabled");
}
};
final Collection<? extends SftpEventListener> listeners = getRegisteredListeners();
if (GenericUtils.size(listeners) > 0) {
for (final SftpEventListener l : listeners) {
subsystem.addSftpEventListener(l);
}
}
return subsystem;
}
示例2: handleAuthenticationFailure
import org.apache.sshd.common.util.GenericUtils; //导入方法依赖的package包/类
protected void handleAuthenticationFailure(int cmd, Buffer buffer) throws Exception {
String username = (currentAuth == null) ? null : currentAuth.getUsername();
ServerSession session = getServerSession();
if (log.isDebugEnabled()) {
log.debug("handleAuthenticationFailure({}@{}) {}",
username, session, SshConstants.getCommandMessageName(cmd));
}
StringBuilder sb = new StringBuilder((authMethods.size() + 1) * Byte.SIZE);
for (List<String> l : authMethods) {
if (GenericUtils.size(l) > 0) {
String m = l.get(0);
if (!UserAuthNoneFactory.NAME.equals(m)) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(m);
}
}
}
String remaining = sb.toString();
if (log.isDebugEnabled()) {
log.debug("handleAuthenticationFailure({}@{}) remaining methods: {}", username, session, remaining);
}
buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_FAILURE, remaining.length() + Byte.SIZE);
buffer.putString(remaining);
buffer.putBoolean(false); // no partial success ...
session.writePacket(buffer);
if (currentAuth != null) {
try {
currentAuth.destroy();
} finally {
currentAuth = null;
}
}
}
示例3: assertListEquals
import org.apache.sshd.common.util.GenericUtils; //导入方法依赖的package包/类
public static <E> void assertListEquals(String message, List<? extends E> expected, List<? extends E> actual) {
int expSize = GenericUtils.size(expected);
int actSize = GenericUtils.size(actual);
assertEquals(message + "[size]", expSize, actSize);
for (int index = 0; index < expSize; index++) {
E expValue = expected.get(index);
E actValue = actual.get(index);
assertEquals(message + "[" + index + "]", expValue, actValue);
}
}
示例4: assertMapEquals
import org.apache.sshd.common.util.GenericUtils; //导入方法依赖的package包/类
public static <K, V> void assertMapEquals(String message, Map<? extends K, ? extends V> expected, Map<? super K, ? extends V> actual) {
int numItems = GenericUtils.size(expected);
assertEquals(message + "[size]", numItems, GenericUtils.size(actual));
if (numItems > 0) {
for (Map.Entry<? extends K, ? extends V> ee : expected.entrySet()) {
K key = ee.getKey();
V expValue = ee.getValue();
V actValue = actual.get(key);
assertEquals(message + "[" + key + "]", expValue, actValue);
}
}
}
示例5: testRemoteForwardingWithDisconnect
import org.apache.sshd.common.util.GenericUtils; //导入方法依赖的package包/类
@Test(timeout = 45000)
public void testRemoteForwardingWithDisconnect() throws Exception {
Session session = createSession();
try {
// 1. Create a Port Forward
int forwardedPort = Utils.getFreePort();
session.setPortForwardingR(forwardedPort, TEST_LOCALHOST, echoPort);
waitForForwardingRequest(TcpipForwardHandler.REQUEST, TimeUnit.SECONDS.toMillis(5L));
// 2. Establish a connection through it
try (Socket s = new Socket(TEST_LOCALHOST, forwardedPort)) {
s.setSoTimeout((int) TimeUnit.SECONDS.toMillis(10L));
// 3. Simulate the client going away
rudelyDisconnectJschSession(session);
// 4. Make sure the NIOprocessor is not stuck
Thread.sleep(TimeUnit.SECONDS.toMillis(1L));
// from here, we need to check all the threads running and find a
// "NioProcessor-"
// that is stuck on a PortForward.dispose
ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
while (root.getParent() != null) {
root = root.getParent();
}
for (int index = 0;; index++) {
Collection<Thread> pending = findThreads(root, "NioProcessor-");
if (GenericUtils.size(pending) <= 0) {
log.info("Finished after " + index + " iterations");
break;
}
try {
Thread.sleep(TimeUnit.SECONDS.toMillis(1L));
} catch (InterruptedException e) {
// ignored
}
}
session.delPortForwardingR(forwardedPort);
}
} finally {
session.disconnect();
}
}