Skip to content

Commit a0ceb89

Browse files
committed
Allfiles
1 parent 0d15eb2 commit a0ceb89

File tree

405 files changed

+192799
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

405 files changed

+192799
-0
lines changed

jar_files/sqlite-jdbc-3.21.0.jar

6.36 MB
Binary file not shown.

mysql-connector-java-5.1.49/mysql-connector-java-5.1.49/CHANGES

Lines changed: 5591 additions & 0 deletions
Large diffs are not rendered by default.

mysql-connector-java-5.1.49/mysql-connector-java-5.1.49/COPYING

Lines changed: 307 additions & 0 deletions
Large diffs are not rendered by default.

mysql-connector-java-5.1.49/mysql-connector-java-5.1.49/README

Lines changed: 2251 additions & 0 deletions
Large diffs are not rendered by default.

mysql-connector-java-5.1.49/mysql-connector-java-5.1.49/README.txt

Lines changed: 2251 additions & 0 deletions
Large diffs are not rendered by default.

mysql-connector-java-5.1.49/mysql-connector-java-5.1.49/build.xml

Lines changed: 1751 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.
Binary file not shown.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
3+
4+
The MySQL Connector/J is licensed under the terms of the GPLv2
5+
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
6+
There are special exceptions to the terms and conditions of the GPLv2 as it is applied to
7+
this software, see the FOSS License Exception
8+
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
9+
10+
This program is free software; you can redistribute it and/or modify it under the terms
11+
of the GNU General Public License as published by the Free Software Foundation; version 2
12+
of the License.
13+
14+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15+
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16+
See the GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License along with this
19+
program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth
20+
Floor, Boston, MA 02110-1301 USA
21+
22+
*/
23+
24+
package com.mysql.fabric;
25+
26+
/**
27+
* Indicates an exceptional condition while communicating with a Fabric server.
28+
*/
29+
public class FabricCommunicationException extends Exception {
30+
31+
private static final long serialVersionUID = 1L;
32+
33+
public FabricCommunicationException(Throwable cause) {
34+
super(cause);
35+
}
36+
37+
public FabricCommunicationException(String message) {
38+
super(message);
39+
}
40+
41+
public FabricCommunicationException(String message, Throwable cause) {
42+
super(message, cause);
43+
}
44+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
3+
4+
The MySQL Connector/J is licensed under the terms of the GPLv2
5+
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
6+
There are special exceptions to the terms and conditions of the GPLv2 as it is applied to
7+
this software, see the FOSS License Exception
8+
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
9+
10+
This program is free software; you can redistribute it and/or modify it under the terms
11+
of the GNU General Public License as published by the Free Software Foundation; version 2
12+
of the License.
13+
14+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15+
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16+
See the GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License along with this
19+
program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth
20+
Floor, Boston, MA 02110-1301 USA
21+
22+
*/
23+
24+
package com.mysql.fabric;
25+
26+
import java.util.HashMap;
27+
import java.util.Map;
28+
import java.util.Set;
29+
import java.util.concurrent.TimeUnit;
30+
31+
import com.mysql.fabric.proto.xmlrpc.XmlRpcClient;
32+
33+
public class FabricConnection {
34+
private XmlRpcClient client;
35+
36+
// internal caches
37+
private Map<String, ShardMapping> shardMappingsByTableName = new HashMap<String, ShardMapping>();
38+
private Map<String, ServerGroup> serverGroupsByName = new HashMap<String, ServerGroup>();
39+
private long shardMappingsExpiration;
40+
private int shardMappingsTtl;
41+
private long serverGroupsExpiration;
42+
private int serverGroupsTtl;
43+
44+
public FabricConnection(String url, String username, String password) throws FabricCommunicationException {
45+
this.client = new XmlRpcClient(url, username, password);
46+
refreshState();
47+
}
48+
49+
/**
50+
* @param urls
51+
* @param username
52+
* @param password
53+
* @throws FabricCommunicationException
54+
*/
55+
public FabricConnection(Set<String> urls, String username, String password) throws FabricCommunicationException {
56+
throw new UnsupportedOperationException("Multiple connections not supported.");
57+
}
58+
59+
public String getInstanceUuid() {
60+
return null;
61+
}
62+
63+
public int getVersion() {
64+
return 0;
65+
}
66+
67+
/**
68+
* @return version of state data
69+
*/
70+
public int refreshState() throws FabricCommunicationException {
71+
FabricStateResponse<Set<ServerGroup>> serverGroups = this.client.getServerGroups();
72+
FabricStateResponse<Set<ShardMapping>> shardMappings = this.client.getShardMappings();
73+
74+
this.serverGroupsExpiration = serverGroups.getExpireTimeMillis();
75+
this.serverGroupsTtl = serverGroups.getTtl();
76+
for (ServerGroup g : serverGroups.getData()) {
77+
this.serverGroupsByName.put(g.getName(), g);
78+
}
79+
80+
this.shardMappingsExpiration = shardMappings.getExpireTimeMillis();
81+
this.shardMappingsTtl = shardMappings.getTtl();
82+
for (ShardMapping m : shardMappings.getData()) {
83+
// a shard mapping may be associated with more than one table
84+
for (ShardTable t : m.getShardTables()) {
85+
this.shardMappingsByTableName.put(t.getDatabase() + "." + t.getTable(), m);
86+
}
87+
}
88+
89+
return 0;
90+
}
91+
92+
public int refreshStatePassive() {
93+
try {
94+
return refreshState();
95+
} catch (FabricCommunicationException e) {
96+
// Fabric node is down but we can operate on previous setup. Just reset the TTL timers.
97+
this.serverGroupsExpiration = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(this.serverGroupsTtl);
98+
this.shardMappingsExpiration = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(this.shardMappingsTtl);
99+
}
100+
101+
return 0;
102+
}
103+
104+
public ServerGroup getServerGroup(String serverGroupName) {
105+
if (isStateExpired()) {
106+
refreshStatePassive();
107+
}
108+
return this.serverGroupsByName.get(serverGroupName);
109+
}
110+
111+
public ShardMapping getShardMapping(String database, String table) {
112+
if (isStateExpired()) {
113+
refreshStatePassive();
114+
}
115+
return this.shardMappingsByTableName.get(database + "." + table);
116+
}
117+
118+
public boolean isStateExpired() {
119+
return System.currentTimeMillis() > this.shardMappingsExpiration || System.currentTimeMillis() > this.serverGroupsExpiration;
120+
}
121+
122+
public Set<String> getFabricHosts() {
123+
return null;
124+
}
125+
126+
public XmlRpcClient getClient() {
127+
return this.client;
128+
}
129+
}

0 commit comments

Comments
 (0)