Skip to content

Commit 91dcc9e

Browse files
committed
tidy up
1 parent 9573bb9 commit 91dcc9e

File tree

3 files changed

+14
-29
lines changed

3 files changed

+14
-29
lines changed

plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs/HdfsBlobContainer.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ public Void run(FileContext fileContext) throws IOException {
131131
}
132132

133133
@Override
134-
public Map<String, BlobMetaData> listBlobsByPrefix(final @Nullable String blobNamePrefix) throws IOException {
134+
public Map<String, BlobMetaData> listBlobsByPrefix(final @Nullable String prefix) throws IOException {
135135
FileStatus[] files = store.execute(new Operation<FileStatus[]>() {
136136
@Override
137137
public FileStatus[] run(FileContext fileContext) throws IOException {
138138
return (fileContext.util().listStatus(path, new PathFilter() {
139139
@Override
140140
public boolean accept(Path path) {
141-
return path.getName().startsWith(blobNamePrefix);
141+
return prefix == null || path.getName().startsWith(prefix);
142142
}
143143
}));
144144
}
@@ -152,16 +152,6 @@ public boolean accept(Path path) {
152152

153153
@Override
154154
public Map<String, BlobMetaData> listBlobs() throws IOException {
155-
FileStatus[] files = store.execute(new Operation<FileStatus[]>() {
156-
@Override
157-
public FileStatus[] run(FileContext fileContext) throws IOException {
158-
return fileContext.util().listStatus(path);
159-
}
160-
});
161-
Map<String, BlobMetaData> map = new LinkedHashMap<String, BlobMetaData>();
162-
for (FileStatus file : files) {
163-
map.put(file.getPath().getName(), new PlainBlobMetaData(file.getPath().getName(), file.getLen()));
164-
}
165-
return Collections.unmodifiableMap(map);
155+
return listBlobsByPrefix(null);
166156
}
167157
}

plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs/HdfsBlobStore.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,6 @@ public Void run(FileContext fileContext) throws IOException {
6666
});
6767
}
6868

69-
@Override
70-
public String toString() {
71-
return root.toUri().toString();
72-
}
73-
74-
@Override
75-
public BlobContainer blobContainer(BlobPath path) {
76-
return new HdfsBlobContainer(path, this, buildHdfsPath(path), bufferSize);
77-
}
78-
7969
@Override
8070
public void delete(BlobPath path) throws IOException {
8171
execute(new Operation<Void>() {
@@ -87,6 +77,16 @@ public Void run(FileContext fc) throws IOException {
8777
});
8878
}
8979

80+
@Override
81+
public String toString() {
82+
return root.toUri().toString();
83+
}
84+
85+
@Override
86+
public BlobContainer blobContainer(BlobPath path) {
87+
return new HdfsBlobContainer(path, this, buildHdfsPath(path), bufferSize);
88+
}
89+
9090
private Path buildHdfsPath(BlobPath blobPath) {
9191
final Path path = translateToHdfsPath(blobPath);
9292
try {
@@ -107,7 +107,6 @@ private Path translateToHdfsPath(BlobPath blobPath) {
107107
return path;
108108
}
109109

110-
111110
interface Operation<V> {
112111
V run(FileContext fileContext) throws IOException;
113112
}
@@ -122,7 +121,7 @@ <V> V execute(Operation<V> operation) throws IOException {
122121
sm.checkPermission(new SpecialPermission());
123122
}
124123
if (closed) {
125-
throw new AlreadyClosedException("HdfsBlobStore is closed: " + root);
124+
throw new AlreadyClosedException("HdfsBlobStore is closed: " + this);
126125
}
127126
try {
128127
return AccessController.doPrivileged(new PrivilegedExceptionAction<V>() {

plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsTests.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import static org.hamcrest.Matchers.greaterThan;
2323

2424
import java.util.Collection;
25-
import java.util.Collections;
2625

2726
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse;
2827
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
@@ -34,9 +33,6 @@
3433
import org.elasticsearch.repositories.RepositoryException;
3534
import org.elasticsearch.repositories.hdfs.HdfsPlugin;
3635
import org.elasticsearch.snapshots.SnapshotState;
37-
import org.elasticsearch.test.ESIntegTestCase;
38-
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
39-
import org.elasticsearch.test.ESIntegTestCase.Scope;
4036
import org.elasticsearch.test.ESSingleNodeTestCase;
4137

4238
public class HdfsTests extends ESSingleNodeTestCase {

0 commit comments

Comments
 (0)