Skip to content

Repository files navigation

SolidFire Java SDK

Java SDK library for interacting with SolidFire Element API

Description

The SolidFire Java SDK is a collection of software modules and libraries that facilitate integration and orchestration between proprietary systems and third-party applications. The Java SDK allows developers to deeply integrate SolidFire system API with the Java programming language. The SolidFire Java SDK reduces the amount of additional coding time required for integration.

Compatibility

ComponentVersion
Java7.0 & 8.0
SolidFire OSElement 11.0 - 12.3

Getting Help

Contacting SolidFire SDK Support If you have any questions or comments about this product, submit an issue on github or reach out to the developer community at ThePub. Your feedback helps us focus our efforts on new features and capabilities.

Download

Download the latest jar:

<dependency>
<groupId>com.solidfire</groupId>
<artifactId>solidfire-sdk-java</artifactId>
<version>12.3.0.196</version>
</dependency>

or SBT:

libraryDependencies +="com.solidfire"%"solidfire-sdk-java"%"12.3"

or Gradle:

compile 'com.solidfire:solidfire-sdk-java:12.3'

##Dependencies

ComponentVersion
base642.3.9
solidfire.code.gson2.6.2
joda-time2.9.3
joda-convert1.8.1
slf4j-api1.7.25

Limitations with a Certificate Signed Assembly Jar

The SDK assembly is signed with a certificate controlled by SolidFire, Inc, assuring the archive is official and legitimate. One caveat to having a set of components also signed with SolidFire's certificate, is no other version of these components can exist on the classpath. This will cause a security exception in the JVM.

Documentation

Latest JavaDoc

Release Notes

Examples

Step 1 - Build a SolidFireElement object using the factory

This is the preferred way to construct the SolidFireElement object. The factory will make a call to the SolidFire cluster using the credentials supplied to test the connection. It will also set the version to communicate with based on the highest number supported by the SDK and Element OS. Optionally, you can choose to set the version manually and whether or not to verify SSL. Read more about it in the ElementFactory documentation.

Java:

importcom.solidfire.client.ElementFactory;
importcom.solidfire.element.api.*;
importcom.solidfire.core.javautil.Optional;
// Import Optional common empty types (String, Long, & Map)importstaticcom.solidfire.core.javautil.Optional.*;
...
// Use ElementFactory to get a SolidFireElement object.SolidFireElementsfe = ElementFactory.create("mvip", "username", "password");

Scala:

importcom.solidfire.client.ElementFactoryimportcom.solidfire.element.api._importcom.solidfire.core.javautil.Optional.{empty, of}
...
// Use ElementFactory to get a SolidFireElement object.valsf=ElementFactory.create( "mvip", "username", "password" )

Step 2 - Call the API method and retrieve the result

All service methods in SolidFireElement call API endpoints and they all return result objects. The naming convention is [methodName]Result. For example, listAccounts() returns a ListAccountsResult object which has a property called getAccounts() returns an array of Accounts that can be iterated.

This example sends a request to list accounts then pulls the first account from the AddAccountResult object.

Java:

// Send the request and wait for the result then pull the AccountListAccountsResultlistAccountsResult = sfe.listAccounts(ListAccountsRequest.builder().build());
Accountaccount = listAccountsResult.getAccounts()[0];

Scala:

// Send the request and wait for the result then pull the first AccountvallistAccountsResult= sfe.listAccounts(ListAccountsRequest.builder.build)
valaccount= listAccountsResult.getAccounts()(0)

Examples of using the API (Java)

importcom.solidfire.client.ElementFactory;
importcom.solidfire.element.api.*;
importcom.solidfire.core.javautil.Optional;
// Import Optional common empty types (String, Long, & Map)importstaticcom.solidfire.core.javautil.Optional.*;
publicclassReadmeJavaExample {
publicstaticvoidmain(String[] args) {
// Create Connection to SF ClusterSolidFireElementsf = ElementFactory.create("mvip", "username", "password", "8.0");
//* --------- EXAMPLE 1 - CREATE AN ACCOUNT ----------- *//// Construct an "AddAccount" request with only required parameters using the builderAddAccountRequestaddAccountRequest = AddAccountRequest.builder()
.username("username")
.build();
// Send the request and pull the account ID from the result objectLongaccountId = sf.addAccount(addAccountRequest).getAccountID();
//* --------- EXAMPLE 2 - CREATE A VOLUME ------------- *//// Construct a request with parameters using the constructor.CreateVolumeRequestcreateVolumeRequest = newCreateVolumeRequest("volumeName", accountId,
1000000000l, false,
Optional.<QoS>empty(),
EMPTY_MAP);
// Send the "CreateVolume" request pull the VolumeID off the result objectLongvolumeId = sf.createVolume(createVolumeRequest).getVolumeID();
//* --------- EXAMPLE 3 - LIST ONE VOLUME FOR AN ACCOUNT ------------- *//// Send the "ListVolume" request with desired parameters inline and pull the first volume in the resultVolumevolume = sf.listVolumesForAccount(accountId, of(volumeId), of(1l)).getVolumes()[0];
// Pull the iqn from the volumeStringiqn = volume.getIqn();
//* --------- EXAMPLE 3 - MODIFY A VOLUME ------------- *//// Change Min and Burst QoS while keeping Max and Burst Time the sameQoSqos = newQoS(of(5000l), EMPTY_LONG, of(30000l), EMPTY_LONG);
// Construct request to modify the volume size and QoS using the builderModifyVolumeRequestmodifyVolumeRequest = ModifyVolumeRequest.builder()
.volumeID(volumeId)
.optionalQos(qos)
.optionalTotalSize(2000000000l)
.build();
// Send the modify volume requestsf.modifyVolume(modifyVolumeRequest);
}
}

Examples of using the API (Scala)

importcom.solidfire.client.ElementFactoryimportcom.solidfire.element.api._importcom.solidfire.core.javautil.Optional.{empty, of}
classReadmeScalaExample {
// Create Connection to SF Clustervalsf=ElementFactory.create( "mvip", "username", "password", "8.0" )
//* --------- EXAMPLE 1 - CREATE AN ACCOUNT ----------- *//// Construct an "AddAccount" request with only required parameters using the buildervaladdAccount=AddAccountRequest.builder.username( "username" ).build
// Send the request and pull the account ID from the result objectvalaccountId= sf.addAccount( addAccount ).getAccountID
//* --------- EXAMPLE 2 - CREATE A VOLUME ------------- *//// Construct a "CreateVolume" request with parameters using the constructor.valcreateVolume=newCreateVolumeRequest( "volumeName", accountId, 1000000000L, false, empty[QoS], empty( ) )
// Send the request pull the VolumeID off the result objectvalvolumeId= sf.createVolume( createVolume ).getVolumeID
//* --------- EXAMPLE 3 - LIST ONE VOLUME FOR AN ACCOUNT ------------- *//// Send the "ListVolume" request with desired parameters inline and pull the first volume in the resultvaliqn:Volume= sf.listVolumesForAccount( accountId, of( volumeId ), of( 1L ) ).getVolumes()(0)
// pull the iqn from the volumevaliqn:String= volume.getIqn
//* --------- EXAMPLE 4 - MODIFY A VOLUME ------------- *//// Change Min and Burst QoS while keeping Max and Burst Time the samevalqos:QoS=newQoS( of( 5000l ), empty(), of( 30000l ), empty() )
// Construct request to modify the volume size and QoS using the builder.valmodifyVolume=ModifyVolumeRequest.builder
.volumeID( volumeId )
.optionalQos( qos )
.optionalTotalSize( 2000000000l )
.build
// Send the modify volume request
sf.modifyVolume( modifyVolume )
}

Timeout

Connection timeout (useful for failing fast when a host becomes unreachable):

Java:

importcom.solidfire.client.ElementFactory;
importcom.solidfire.element.api.*;
...
SolidFireElementsfe = ElementFactory.create("ip-address-of-cluster", "username", "password");
sfe.getRequestDispatcher().setConnectionTimeout(600);

Read timeout (useful for extending time for a service call to return):

Java:

importcom.solidfire.client.ElementFactory;
importcom.solidfire.element.api.*;
...
SolidFireElementsfe = ElementFactory.create("ip-address-of-cluster", "username", "password");
sfe.getRequestDispatcher().setReadTimeout(600);

For more examples check out the tutorials in the examples folder of this repo.

Logging and Logback

The SDK and the Assembly leverage the SLF4J API for logging with the assembly also including logback-classic implementation. An advantage to using the SLF4J interface is the availability of legacy logging framework bridges, for intercepting and consolidating all logging calls into a single log.

Logback (Assembly Only) Tracing Request / Response calls in the log

An example logback.xml:

<configurationdebug="true">
<appendername="STDOUT"class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<loggername="com.solidfire.core.client.ServiceBase"level="DEBUG" />
<rootlevel="INFO">
<appender-refref="STDOUT" />
</root>
</configuration>

You also need to add the appropriate SLF4J dependency. Continuing with the logback example:

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>

License

Copyright © 2021 NetApp, Inc. All rights reserved.

Licensed 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 andlimitations under the License.

Releases

Packages

Contributors

Languages