1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-05-19 18:01:03 +02:00

HCFS: 1.22

fix put gives java.lang.NoSuchFieldError: INSTANCE related to Cloudera CDH Hadoop https://github.com/chrislusf/seaweedfs/issues/1080
This commit is contained in:
Chris Lu 2019-10-11 21:44:44 -07:00
parent 7a707617e5
commit 7057e7a076
7 changed files with 21 additions and 14 deletions

View file

@ -4,7 +4,7 @@
<groupId>com.github.chrislusf</groupId>
<artifactId>seaweedfs-client</artifactId>
<version>1.1.9</version>
<version>1.2.2</version>
<parent>
<groupId>org.sonatype.oss</groupId>

View file

@ -7,6 +7,7 @@ import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
@ -19,7 +20,7 @@ public class SeaweedRead {
// returns bytesRead
public static long read(FilerGrpcClient filerGrpcClient, List<VisibleInterval> visibleIntervals,
final long position, final byte[] buffer, final int bufferOffset,
final int bufferLength) {
final int bufferLength) throws IOException {
List<ChunkView> chunkViews = viewFromVisibles(visibleIntervals, position, bufferLength);
@ -54,7 +55,7 @@ public class SeaweedRead {
return readCount;
}
private static int readChunkView(long position, byte[] buffer, int startOffset, ChunkView chunkView, FilerProto.Locations locations) {
private static int readChunkView(long position, byte[] buffer, int startOffset, ChunkView chunkView, FilerProto.Locations locations) throws IOException {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(
String.format("http://%s/%s", locations.getLocations(0).getUrl(), chunkView.fileId));
@ -76,10 +77,12 @@ public class SeaweedRead {
return len;
} catch (IOException e) {
e.printStackTrace();
} finally {
if (client instanceof Closeable) {
Closeable t = (Closeable) client;
t.close();
}
}
return 0;
}
protected static List<ChunkView> viewFromVisibles(List<VisibleInterval> visibleIntervals, long offset, long size) {

View file

@ -1,13 +1,14 @@
package seaweedfs.client;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.DefaultHttpClient;
import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
@ -59,7 +60,7 @@ public class SeaweedWrite {
final byte[] bytes,
final long bytesOffset, final long bytesLength) throws IOException {
CloseableHttpClient client = HttpClientBuilder.create().setUserAgent("hdfs-client").build();
HttpClient client = new DefaultHttpClient();
InputStream inputStream = new ByteArrayInputStream(bytes, (int) bytesOffset, (int) bytesLength);
@ -84,7 +85,10 @@ public class SeaweedWrite {
return etag;
} finally {
client.close();
if (client instanceof Closeable) {
Closeable t = (Closeable) client;
t.close();
}
}
}

View file

@ -123,7 +123,7 @@
</snapshotRepository>
</distributionManagement>
<properties>
<seaweedfs.client.version>1.1.9</seaweedfs.client.version>
<seaweedfs.client.version>1.2.2</seaweedfs.client.version>
<hadoop.version>2.9.2</hadoop.version>
</properties>
</project>

View file

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<properties>
<seaweedfs.client.version>1.1.9</seaweedfs.client.version>
<seaweedfs.client.version>1.2.2</seaweedfs.client.version>
<hadoop.version>2.9.2</hadoop.version>
</properties>

View file

@ -123,7 +123,7 @@
</snapshotRepository>
</distributionManagement>
<properties>
<seaweedfs.client.version>1.1.9</seaweedfs.client.version>
<seaweedfs.client.version>1.2.2</seaweedfs.client.version>
<hadoop.version>3.1.1</hadoop.version>
</properties>
</project>

View file

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<properties>
<seaweedfs.client.version>1.1.9</seaweedfs.client.version>
<seaweedfs.client.version>1.2.2</seaweedfs.client.version>
<hadoop.version>3.1.1</hadoop.version>
</properties>