Skip to content

Commit 17ac4df

Browse files
committed
first commit
0 parents  commit 17ac4df

File tree

394 files changed

+185545
-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.

394 files changed

+185545
-0
lines changed

.classpath

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4+
<classpathentry kind="src" path="src"/>
5+
<classpathentry kind="lib" path="C:/Program Files/mysql-connector-java-5.1.49/mysql-connector-java-5.1.49.jar"/>
6+
<classpathentry kind="lib" path="C:/Program Files/mysql-connector-java-5.1.49/mysql-connector-java-5.1.49-bin.jar"/>
7+
<classpathentry kind="output" path="bin"/>
8+
</classpath>

.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>todolist</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

.settings/org.eclipse.jdt.core.prefs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.release=disabled
12+
org.eclipse.jdt.core.compiler.source=1.8

OUTPUT.PNG

9.93 KB
Loading

bin/todolist/DB.class

1.01 KB
Binary file not shown.

bin/todolist/todo$1.class

699 Bytes
Binary file not shown.

bin/todolist/todo$2.class

3.57 KB
Binary file not shown.

bin/todolist/todo$3.class

4.22 KB
Binary file not shown.

bin/todolist/todo$4.class

3.28 KB
Binary file not shown.

bin/todolist/todo$5.class

1.43 KB
Binary file not shown.

bin/todolist/todo$6.class

901 Bytes
Binary file not shown.

bin/todolist/todo$7.class

729 Bytes
Binary file not shown.

bin/todolist/todo$8.class

633 Bytes
Binary file not shown.

bin/todolist/todo$9.class

1.4 KB
Binary file not shown.

bin/todolist/todo.class

5.19 KB
Binary file not shown.

mysql-connector-java-5.1.49/CHANGES

+5,591
Large diffs are not rendered by default.

mysql-connector-java-5.1.49/COPYING

+307
Large diffs are not rendered by default.

mysql-connector-java-5.1.49/README

+2,251
Large diffs are not rendered by default.

mysql-connector-java-5.1.49/README.txt

+2,251
Large diffs are not rendered by default.

mysql-connector-java-5.1.49/build.xml

+1,751
Large diffs are not rendered by default.
Binary file not shown.
Binary file not shown.
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+
}
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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.concurrent.TimeUnit;
27+
28+
public class FabricStateResponse<T> {
29+
private T data;
30+
private int secsTtl;
31+
private long expireTimeMillis;
32+
33+
public FabricStateResponse(T data, int secsTtl) {
34+
this.data = data;
35+
this.secsTtl = secsTtl;
36+
this.expireTimeMillis = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(secsTtl);
37+
}
38+
39+
public FabricStateResponse(T data, int secsTtl, long presetExpireTimeMillis) {
40+
this.data = data;
41+
this.secsTtl = secsTtl;
42+
this.expireTimeMillis = presetExpireTimeMillis;
43+
}
44+
45+
public T getData() {
46+
return this.data;
47+
}
48+
49+
public int getTtl() {
50+
return this.secsTtl;
51+
}
52+
53+
/**
54+
* The expiration time of this data. Should be compared to {@link System.currentTimeMillis()}.
55+
*/
56+
public long getExpireTimeMillis() {
57+
return this.expireTimeMillis;
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
Copyright (c) 2013, 2017, 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.math.BigInteger;
27+
import java.security.MessageDigest;
28+
import java.util.Comparator;
29+
import java.util.Set;
30+
import java.util.TreeSet;
31+
32+
/**
33+
* A shard mapping with ranges defined by hashing key values. Lookups work essentially
34+
* the same as in {@link RangeShardMapping} but strings are compared as opposed to ints.
35+
*/
36+
public class HashShardMapping extends ShardMapping {
37+
private static class ReverseShardIndexSorter implements Comparator<ShardIndex> {
38+
public int compare(ShardIndex i1, ShardIndex i2) {
39+
return i2.getBound().compareTo(i1.getBound());
40+
}
41+
42+
// singleton instance
43+
public static final ReverseShardIndexSorter instance = new ReverseShardIndexSorter();
44+
}
45+
46+
private static final MessageDigest md5Hasher;
47+
48+
static {
49+
try {
50+
md5Hasher = MessageDigest.getInstance("MD5");
51+
} catch (java.security.NoSuchAlgorithmException ex) {
52+
throw new ExceptionInInitializerError(ex);
53+
}
54+
}
55+
56+
public HashShardMapping(int mappingId, ShardingType shardingType, String globalGroupName, Set<ShardTable> shardTables, Set<ShardIndex> shardIndices) {
57+
super(mappingId, shardingType, globalGroupName, shardTables, new TreeSet<ShardIndex>(ReverseShardIndexSorter.instance));
58+
this.shardIndices.addAll(shardIndices);
59+
}
60+
61+
@Override
62+
protected ShardIndex getShardIndexForKey(String stringKey) {
63+
String hashedKey;
64+
synchronized (md5Hasher) {
65+
hashedKey = new BigInteger(/* unsigned/positive */1, md5Hasher.digest(stringKey.getBytes())).toString(16).toUpperCase();
66+
}
67+
68+
// pad out to 32 digits
69+
for (int i = 0; i < (32 - hashedKey.length()); ++i) {
70+
hashedKey = "0" + hashedKey;
71+
}
72+
73+
for (ShardIndex i : this.shardIndices) {
74+
if (i.getBound().compareTo(hashedKey) <= 0) {
75+
return i;
76+
}
77+
}
78+
79+
// default to the first (highest) bound,
80+
// implementing wrapping
81+
return this.shardIndices.iterator().next();
82+
}
83+
}

0 commit comments

Comments
 (0)