本文整理汇总了Java中org.apache.derby.drda.NetworkServerControl.ping方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkServerControl.ping方法的具体用法?Java NetworkServerControl.ping怎么用?Java NetworkServerControl.ping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.derby.drda.NetworkServerControl
的用法示例。
在下文中一共展示了NetworkServerControl.ping方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startNetworkServer
import org.apache.derby.drda.NetworkServerControl; //导入方法依赖的package包/类
public static NetworkServerControl startNetworkServer(final int netPort)
throws Exception {
getLogWriter().info(
"Starting a Derby Network Server on "
+ InetAddress.getLocalHost().getHostName() + ":" + netPort);
NetworkServerControl server = new NetworkServerControl(
InetAddress.getLocalHost(), netPort);
// send the output to derby logs
server.start(SanityManager.GET_DEBUG_STREAM());
// wait for n/w server to initialize completely
while (true) {
Thread.sleep(500);
try {
server.ping();
break;
}
catch (Exception e) {
}
}
server.logConnections(true);
return server;
}
示例2: isServerStarted
import org.apache.derby.drda.NetworkServerControl; //导入方法依赖的package包/类
private static boolean isServerStarted(NetworkServerControl server, int ntries)
{
for (int i = 1; i <= ntries; i ++)
{
try {
Thread.sleep(500);
server.ping();
return true;
}
catch (Exception e) {
if (i == ntries)
return false;
}
}
return false;
}
示例3: waitForDerbyInitialization
import org.apache.derby.drda.NetworkServerControl; //导入方法依赖的package包/类
public static void waitForDerbyInitialization(NetworkServerControl server)
throws InterruptedException {
for (int tries = 1; tries <= 20; tries++) {
try {
server.ping();
break;
} catch (Throwable t) {
Thread.sleep(1000);
}
}
}
示例4: startDatabase
import org.apache.derby.drda.NetworkServerControl; //导入方法依赖的package包/类
@BeforeClass
public static void startDatabase() throws Exception {
ServerSocket socket = new ServerSocket(0);
port = socket.getLocalPort();
socket.close();
LOG.info("Starting Derby database on {}", port);
System.setProperty("derby.stream.error.file", "target/derby.log");
derbyServer = new NetworkServerControl(InetAddress.getByName("localhost"), port);
StringWriter out = new StringWriter();
derbyServer.start(new PrintWriter(out));
boolean started = false;
int count = 0;
// Use two different methods to detect when server is started:
// 1) Check the server stdout for the "started" string
// 2) wait up to 15 seconds for the derby server to start based on a ping
// on faster machines and networks, this may return very quick, but on slower
// networks where the DNS lookups are slow, this may take a little time
while (!started && count < 30) {
if (out.toString().contains("started")) {
started = true;
} else {
count++;
Thread.sleep(500);
try {
derbyServer.ping();
started = true;
} catch (Throwable t) {
//ignore, still trying to start
}
}
}
dataSource = new ClientDataSource();
dataSource.setCreateDatabase("create");
dataSource.setDatabaseName("target/beam");
dataSource.setServerName("localhost");
dataSource.setPortNumber(port);
readTableName = JdbcTestHelper.getTableName("UT_READ");
JdbcTestHelper.createDataTable(dataSource, readTableName);
addInitialData(dataSource, readTableName);
}