-
Notifications
You must be signed in to change notification settings - Fork 897
Expand file tree
/
Copy pathTrackerServer.java
More file actions
63 lines (55 loc) · 1.6 KB
/
TrackerServer.java
File metadata and controls
63 lines (55 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* Copyright (C) 2008 Happy Fish / YuQing
* <p>
* FastDFS Java Client may be copied only under the terms of the GNU Lesser
* General Public License (LGPL).
* Please visit the FastDFS Home Page https://github.com/happyfish100/fastdfs for more detail.
*/
package org.csource.fastdfs;
import org.csource.fastdfs.pool.Connection;
import org.csource.fastdfs.pool.ConnectionPool;
import org.csource.fastdfs.pool.ConnectionFactory;
import java.io.IOException;
import java.net.InetSocketAddress;
/**
* Tracker Server Info
*
* @author Happy Fish / YuQing
* @version Version 1.11
*/
public class TrackerServer {
protected InetSocketAddress inetSockAddr;
public TrackerServer(InetSocketAddress inetSockAddr) throws IOException{
this.inetSockAddr = inetSockAddr;
checkServerEnabled();
}
public Connection getConnection() throws IOException {
Connection connection;
if (ClientGlobal.g_connection_pool_enabled) {
connection = ConnectionPool.getConnection(this.inetSockAddr);
} else {
connection = ConnectionFactory.create(this.inetSockAddr);
}
return connection;
}
/**
* get the server info
*
* @return the server info
*/
public InetSocketAddress getInetSocketAddress() {
return this.inetSockAddr;
}
/**
* check server enabled
* @throws IOException
*/
public void checkServerEnabled() throws IOException {
Connection connection = getConnection();
try {
connection.release();
}catch (Exception e){
//ignore
}
}
}