forked from TrueCloudLab/frostfs-sdk-java
Compare commits
3 commits
bugfix/val
...
master
Author | SHA1 | Date | |
---|---|---|---|
3c3ed76727 | |||
|
73d5e6d72d | ||
|
aa3cff5a03 |
13 changed files with 44 additions and 17 deletions
3
CODEOWNERS
Normal file
3
CODEOWNERS
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
.* @orikik
|
||||||
|
.forgejo/.* @potyarkin
|
||||||
|
Makefile @potyarkin
|
|
@ -10,6 +10,7 @@
|
||||||
<module name="FileTabCharacter">
|
<module name="FileTabCharacter">
|
||||||
<property name="eachLine" value="true"/>
|
<property name="eachLine" value="true"/>
|
||||||
</module>
|
</module>
|
||||||
|
<module name="NewlineAtEndOfFile"/>
|
||||||
|
|
||||||
<!-- Checks for Size Violations. -->
|
<!-- Checks for Size Violations. -->
|
||||||
<!-- See http://checkstyle.sf.net/config_sizes.html -->
|
<!-- See http://checkstyle.sf.net/config_sizes.html -->
|
||||||
|
@ -20,6 +21,15 @@
|
||||||
<module name="TreeWalker">
|
<module name="TreeWalker">
|
||||||
<property name="tabWidth" value="4"/>
|
<property name="tabWidth" value="4"/>
|
||||||
|
|
||||||
|
<module name="Regexp">
|
||||||
|
<property name="message" value="Blank line at end of the block is not allowed"/>
|
||||||
|
<property name="format" value="^\s*$^\s*\}"/>
|
||||||
|
<property name="ignoreComments" value="true"/>
|
||||||
|
<property name="illegalPattern" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="HideUtilityClassConstructor" />
|
||||||
|
|
||||||
<module name="SuppressWarningsHolder" />
|
<module name="SuppressWarningsHolder" />
|
||||||
|
|
||||||
<!-- Checks for Naming Conventions. -->
|
<!-- Checks for Naming Conventions. -->
|
||||||
|
|
|
@ -8,4 +8,4 @@ import java.lang.annotation.Target;
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface NotNull {
|
public @interface NotNull {
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import info.frostfs.sdk.dto.session.SessionToken;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@ -16,7 +16,7 @@ public class PutObjectParameters {
|
||||||
private ObjectHeader header;
|
private ObjectHeader header;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private FileInputStream payload;
|
private InputStream payload;
|
||||||
|
|
||||||
private boolean clientCut;
|
private boolean clientCut;
|
||||||
private int bufferMaxSize;
|
private int bufferMaxSize;
|
||||||
|
@ -26,14 +26,14 @@ public class PutObjectParameters {
|
||||||
private long currentStreamPosition;
|
private long currentStreamPosition;
|
||||||
private long fullLength;
|
private long fullLength;
|
||||||
|
|
||||||
public PutObjectParameters(ObjectHeader header, FileInputStream payload, boolean clientCut, int bufferMaxSize) {
|
public PutObjectParameters(ObjectHeader header, InputStream payload, boolean clientCut, int bufferMaxSize) {
|
||||||
this.header = header;
|
this.header = header;
|
||||||
this.payload = payload;
|
this.payload = payload;
|
||||||
this.clientCut = clientCut;
|
this.clientCut = clientCut;
|
||||||
this.bufferMaxSize = bufferMaxSize;
|
this.bufferMaxSize = bufferMaxSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PutObjectParameters(ObjectHeader header, FileInputStream payload) {
|
public PutObjectParameters(ObjectHeader header, InputStream payload) {
|
||||||
this.header = header;
|
this.header = header;
|
||||||
this.payload = payload;
|
this.payload = payload;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,4 @@ public interface ApeManagerClient {
|
||||||
void removeChain(Chain chain, ChainTarget chainTarget);
|
void removeChain(Chain chain, ChainTarget chainTarget);
|
||||||
|
|
||||||
List<Chain> listChains(ChainTarget chainTarget);
|
List<Chain> listChains(ChainTarget chainTarget);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,4 @@ public class ContextAccessor {
|
||||||
public ContextAccessor(ClientEnvironment context) {
|
public ContextAccessor(ClientEnvironment context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ import info.frostfs.sdk.tools.Verifier;
|
||||||
import info.frostfs.sdk.utils.Validator;
|
import info.frostfs.sdk.utils.Validator;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -329,17 +329,17 @@ public class ObjectClientImpl extends ContextAccessor implements ObjectClient {
|
||||||
return new SearchReader(objectServiceBlockingClient.search(initRequest));
|
return new SearchReader(objectServiceBlockingClient.search(initRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int readNBytes(FileInputStream fileInputStream, byte[] buffer, int size) {
|
private int readNBytes(InputStream inputStream, byte[] buffer, int size) {
|
||||||
try {
|
try {
|
||||||
return fileInputStream.readNBytes(buffer, 0, size);
|
return inputStream.readNBytes(buffer, 0, size);
|
||||||
} catch (IOException exp) {
|
} catch (IOException exp) {
|
||||||
throw new ProcessFrostFSException(exp.getMessage());
|
throw new ProcessFrostFSException(exp.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getStreamSize(FileInputStream fileInputStream) {
|
private long getStreamSize(InputStream inputStream) {
|
||||||
try {
|
try {
|
||||||
return fileInputStream.getChannel().size();
|
return inputStream.available();
|
||||||
} catch (IOException exp) {
|
} catch (IOException exp) {
|
||||||
throw new ProcessFrostFSException(exp.getMessage());
|
throw new ProcessFrostFSException(exp.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,5 +23,4 @@ public class SessionToolsImpl extends ContextAccessor implements SessionTools {
|
||||||
|
|
||||||
return SessionMapper.deserializeSessionToken(sessionToken.getToken());
|
return SessionMapper.deserializeSessionToken(sessionToken.getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,21 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Labels {
|
public class Labels {
|
||||||
/** Merges two string lists into an array, maintaining order of first list then second list. */
|
private Labels() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges two string lists into an array, maintaining order of first list then second list.
|
||||||
|
*/
|
||||||
static String[] asArray(List<String> firstList, List<String> secondList) {
|
static String[] asArray(List<String> firstList, List<String> secondList) {
|
||||||
List<String> list = new ArrayList<>(firstList);
|
List<String> list = new ArrayList<>(firstList);
|
||||||
list.addAll(secondList);
|
list.addAll(secondList);
|
||||||
return list.toArray(new String[0]);
|
return list.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Converts a list of strings to a list of grpc metadata keys. */
|
/**
|
||||||
|
* Converts a list of strings to a list of grpc metadata keys.
|
||||||
|
*/
|
||||||
static List<Key<String>> metadataKeys(List<String> headerNames) {
|
static List<Key<String>> metadataKeys(List<String> headerNames) {
|
||||||
List<Key<String>> keys = new ArrayList<>();
|
List<Key<String>> keys = new ArrayList<>();
|
||||||
for (String name : headerNames) {
|
for (String name : headerNames) {
|
||||||
|
@ -41,7 +48,9 @@ public class Labels {
|
||||||
return Collections.unmodifiableList(labels);
|
return Collections.unmodifiableList(labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds standard labels, as well as custom ones, in order, to a given collector. */
|
/**
|
||||||
|
* Adds standard labels, as well as custom ones, in order, to a given collector.
|
||||||
|
*/
|
||||||
static <T> T addLabels(SimpleCollector<T> collector, List<String> labels, GrpcMethod method) {
|
static <T> T addLabels(SimpleCollector<T> collector, List<String> labels, GrpcMethod method) {
|
||||||
List<String> allLabels = new ArrayList<>();
|
List<String> allLabels = new ArrayList<>();
|
||||||
allLabels.add(method.type());
|
allLabels.add(method.type());
|
||||||
|
|
|
@ -119,5 +119,4 @@ public class RequestSigner {
|
||||||
MessageHelper.setField(verifyBuilder, ORIGIN_SIGNATURE_FIELD_NAME, signMessagePart(key, verifyOrigin));
|
MessageHelper.setField(verifyBuilder, ORIGIN_SIGNATURE_FIELD_NAME, signMessagePart(key, verifyOrigin));
|
||||||
MessageHelper.setField(request, VERIFY_HEADER_FIELD_NAME, verifyBuilder.build());
|
MessageHelper.setField(request, VERIFY_HEADER_FIELD_NAME, verifyBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,9 @@ import static info.frostfs.sdk.constants.ErrorConst.FIELDS_DELIMITER_COMMA;
|
||||||
import static java.util.Objects.isNull;
|
import static java.util.Objects.isNull;
|
||||||
|
|
||||||
public class Validator {
|
public class Validator {
|
||||||
|
private Validator() {
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> void validate(T object) {
|
public static <T> void validate(T object) {
|
||||||
StringBuilder errorMessage = new StringBuilder();
|
StringBuilder errorMessage = new StringBuilder();
|
||||||
process(object, errorMessage);
|
process(object, errorMessage);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package info.frostfs.sdk.utils;
|
package info.frostfs.sdk.utils;
|
||||||
|
|
||||||
public class WaitUtil {
|
public class WaitUtil {
|
||||||
|
private WaitUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
public static void sleep(long ms) {
|
public static void sleep(long ms) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -46,4 +46,7 @@ public class FilterConst {
|
||||||
|
|
||||||
// FILTER_HEADER_PHY is a filter key to check if an object physically stored on a node.
|
// FILTER_HEADER_PHY is a filter key to check if an object physically stored on a node.
|
||||||
public static final String FILTER_HEADER_PHY = HEADER_PREFIX + "PHY";
|
public static final String FILTER_HEADER_PHY = HEADER_PREFIX + "PHY";
|
||||||
|
|
||||||
|
private FilterConst() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue