Unable to take snapshot and restore using repository-hdfs

I am using ES 1.1.1 and Hadoop hortonworks 2.2.2 and have installed the
plugin 'repository-hdfs'
(https://github.com/elasticsearch/elasticsearch-hadoop/tree/master/repository-hdfs
https://github.com/elasticsearch/elasticsearch-hadoop/tree/master/repository-hdfs)
in
ES. I have created one custom plugin action which invokes snapshot and
restore and set hadoop related jars to ES_CLASSPATH

The handleRequest(...) of the custom plugin action looks as below :
public void handleRequest(final RestRequest request,
final RestChannel channel) {
LocalFileSystem fs = FileSystem.getLocal(new Configuration());
Path path = new Path("backup");
fs.delete(path, true);

PutRepositoryResponse putRepositoryResponse = 

client.admin().cluster().preparePutRepository("test-backup").setType("hdfs").
.setSettings(ImmutableSettings.settingsBuilder().put("path", path)).get();

CreateSnapshotResponse createSnapshotResponse = 

client.admin().cluster().prepareCreateSnapshot("test-backup",
"test-snap").setWaitForCompletion(true).setIndices("test").get();

client.admin().cluster().prepareGetSnapshots("test-backup").setSnapshots("test-snap").get().getSnapshots().get(0).state();

RestoreSnapshotResponse restoreSnapshotResponse = 
 client.admin().cluster().prepareRestoreSnapshot("test-backup", 

"test-snap").setIndices("test").setWaitForCompletion(true).execute().actionGet();

XContentBuilder builder = restContentBuilder(request);

builder.value("successfully done - " +
putRepositoryResponse.isAcknowledged() +":"+
createSnapshotResponse.getSnapshotInfo().status().getStatus()+
":"+restoreSnapshotResponse.getRestoreInfo().status().getStatus());
channel
.sendResponse(new XContentRestResponse(request, OK, builder));
}

After the first invocation, I get this error
{"error":"UncategorizedExecutionException[Failed execution]; nested:
IOException[Filesystem closed]; ","status":500}
org.elasticsearch.snapshots.SnapshotCreationException:
[test-backup:test-snap] failed to create snapshot
at
org.elasticsearch.repositories.blobstore.BlobStoreRepository.initializeSnapshot(BlobStoreRepository.java:251)
at
org.elasticsearch.snapshots.SnapshotsService.beginSnapshot(SnapshotsService.java:266)
at
org.elasticsearch.snapshots.SnapshotsService.access$600(SnapshotsService.java:82)
at
org.elasticsearch.snapshots.SnapshotsService$1$1.run(SnapshotsService.java:192)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: Filesystem closed
at org.apache.hadoop.hdfs.DFSClient.checkOpen(DFSClient.java:629)
at org.apache.hadoop.hdfs.DFSClient.create(DFSClient.java:1365)
at org.apache.hadoop.hdfs.DFSClient.create(DFSClient.java:1307)
at
org.apache.hadoop.hdfs.DistributedFileSystem$6.doCall(DistributedFileSystem.java:384)
at
org.apache.hadoop.hdfs.DistributedFileSystem$6.doCall(DistributedFileSystem.java:380)
at
org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
at
org.apache.hadoop.hdfs.DistributedFileSystem.create(DistributedFileSystem.java:380)
at
org.apache.hadoop.hdfs.DistributedFileSystem.create(DistributedFileSystem.java:324)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:905)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:886)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:783)
at
org.elasticsearch.hadoop.hdfs.blobstore.HdfsImmutableBlobContainer$1.run(HdfsImmutableBlobContainer.java:47)
... 3 more

When the action is invoked second time, it throws
{"error":"InvalidSnapshotNameException[[test-backup:test-snap] Invalid
snapshot name [test-snap], snapshot with such name already
exists]","status":400}
org.elasticsearch.snapshots.InvalidSnapshotNameException:
[test-backup:test-snap] Invalid snapshot name [test-snap], snapshot with
such name already exists
at
org.elasticsearch.repositories.blobstore.BlobStoreRepository.initializeSnapshot(BlobStoreRepository.java:224)
at
org.elasticsearch.snapshots.SnapshotsService.beginSnapshot(SnapshotsService.java:266)
at
org.elasticsearch.snapshots.SnapshotsService.access$600(SnapshotsService.java:82)
at
org.elasticsearch.snapshots.SnapshotsService$1$1.run(SnapshotsService.java:192)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

Someone pls help me to fix this exception

Thanks

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f3777bf3-07f2-482b-a877-178f5ebf49d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.