forked from apache/accumulo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06cb5ed
commit 1c07fa6
Showing
3 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
core/src/main/java/org/apache/accumulo/core/client/AccumuloClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.accumulo.core.client; | ||
|
||
import java.io.InputStream; | ||
import java.util.Map; | ||
|
||
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken; | ||
|
||
/** | ||
* <pre> | ||
* <code> | ||
* // Create a connector using properties files | ||
* String clientProps = "accumulo.properties"; | ||
* Connector conn = AccumuloClient.builder().usingProperties(clientProps).build(); | ||
* | ||
* // Create a connector with builder | ||
* Connector conn = AccumuloClient.builder() | ||
* .forInstance("inst1", "zkServer") | ||
* .usingCredentials("root", new PasswordToken("abcd1234")) | ||
* .withSsl() | ||
* .build(); | ||
* </code> | ||
* </pre> | ||
* | ||
* @author !SpongeBob | ||
* | ||
* @since 1.9 | ||
*/ | ||
public class AccumuloClient { | ||
|
||
public interface ConnectorFactory { | ||
Connector build(); | ||
} | ||
|
||
public interface InstanceArgs { | ||
AuthenticationArgs forInstance(String instanceName, String zookeepers); | ||
} | ||
|
||
/** | ||
* Allow specifying a properties file containing at least instance, zookeepers, and credentials. | ||
*/ | ||
public interface PropertyFileOptions extends InstanceArgs { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
ConnectorFactory usingProperties(String file); | ||
|
||
ConnectorFactory usingProperties(InputStream in); | ||
|
||
ConnectorFactory usingProperties(Map<String,String> props); | ||
} | ||
|
||
public interface AuthenticationArgs { | ||
ConnectionOptions usingCredentials(String principal, AuthenticationToken token); | ||
} | ||
|
||
public interface SslOptions extends ConnectorFactory { | ||
public SslOptions withTruststore(String path); | ||
|
||
public SslOptions withTruststore(String path, String password, String type); | ||
|
||
public SslOptions withKeystore(String path); | ||
|
||
public SslOptions withKeystore(String path, String password, String type); | ||
} | ||
|
||
public interface SaslOptions extends ConnectorFactory { | ||
public SaslOptions withPrimary(String kerberosServerPrimary); | ||
} | ||
|
||
public interface ConnectionOptions extends ConnectorFactory { | ||
public ConnectionOptions withZkTimeout(int timeout); | ||
|
||
public SslOptions withSsl(); | ||
|
||
public SaslOptions withSasl(); | ||
} | ||
|
||
public static PropertyFileOptions builder() { | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The implementation of this could use commons config, but its not exposed in API.