src/java.sql/share/classes/java/sql/ShardingKey.java
author kbarrett
Fri, 15 Nov 2019 16:58:29 -0500
changeset 59115 a129f10e1b9a
parent 47216 71c04702a3d5
permissions -rw-r--r--
8233280: Remove GCLockerInvokesConcurrent Summary: Remove use and make option obsolete. Reviewed-by: tschatzl, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34338
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     1
/*
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     4
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    10
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    15
 * accompanied this code).
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    16
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    20
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    23
 * questions.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    24
 */
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    25
package java.sql;
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    26
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    27
/**
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    28
 * Interface used to indicate that this object represents a Sharding Key. A
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    29
 * {@code ShardingKey} instance is only guaranteed to be compatible with the
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    30
 * data source instance that it was derived from. A {@code ShardingKey} is
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    31
 * created using {@link ShardingKeyBuilder}.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    32
 * <p>
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    33
 * The following example illustrates the use of {@link ShardingKeyBuilder} to
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    34
 * create a {@code ShardingKey}:
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    35
 * <pre>
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    36
 * {@code
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    37
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    38
 *     DataSource ds = new MyDataSource();
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    39
 *     ShardingKey shardingKey = ds.createShardingKeyBuilder()
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    40
 *                           .subkey("abc", JDBCType.VARCHAR)
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    41
 *                           .subkey(94002, JDBCType.INTEGER)
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    42
 *                           .build();
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    43
 * }
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    44
 * </pre>
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    45
 * <p>
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    46
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    47
 * A {@code ShardingKey} may also be used for specifying a
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    48
 * {@code superShardingKey}. Databases that support composite Sharding may use a
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    49
 * {@code superShardingKey} to specify a additional level of partitioning within
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    50
 * the Shard.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    51
 * <p>
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    52
 * The following example illustrates the use of {@link ShardingKeyBuilder} to
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    53
 * create a {@code superShardingKey} for an eastern region with a
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    54
 * {@code ShardingKey} specified for the Pittsburgh branch office:
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    55
 * <pre>
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    56
 * {@code
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    57
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    58
 *     DataSource ds = new MyDataSource();
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    59
 *     ShardingKey superShardingKey = ds.createShardingKeyBuilder()
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    60
 *                           .subkey("EASTERN_REGION", JDBCType.VARCHAR)
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    61
 *                           .build();
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    62
 *     ShardingKey shardingKey = ds.createShardingKeyBuilder()
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    63
 *                           .subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    64
 *                           .build();
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    65
 *     Connection con = ds.createConnectionBuilder()
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    66
 *                           .superShardingKey(superShardingKey)
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    67
 *                           .shardingKey(shardingKey)
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    68
 *                           .build();
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    69
 * }
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    70
 * </pre>
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    71
 *
35302
e4d2275861c3 8136494: Update "@since 1.9" to "@since 9" to match java.version.specification
iris
parents: 34338
diff changeset
    72
 * @since 9
34338
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    73
 */
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    74
public interface ShardingKey {
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    75
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    76
}