forked from microsoft/hdfs-mount
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathFaultTolerantHdfsWriter.go
44 lines (37 loc) · 1.3 KB
/
FaultTolerantHdfsWriter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
package main
// Implements HdfsWriter interface with automatic retries (acts as a proxy to HdfsWriter)
type FaultTolerantHdfsWriter struct {
Impl HdfsWriter
}
var _ HdfsWriter = (*FaultTolerantHdfsWriter)(nil) // ensure FaultTolerantHdfsWriterImpl implements HdfsWriter
// Creates new instance of FaultTolerantHdfsWriter
func NewFaultTolerantHdfsWriter(impl HdfsWriter) HdfsWriter {
return &FaultTolerantHdfsWriter{Impl: impl}
}
// Seeks to a given position
func (ftw *FaultTolerantHdfsWriter) Seek(pos int64) error {
// TODO: implement fault tolerance
return ftw.Impl.Seek(pos)
}
// Writes chunk of data
func (ftw *FaultTolerantHdfsWriter) Write(buffer []byte) (int, error) {
// TODO: implement fault tolerance
return ftw.Impl.Write(buffer)
}
// Flushes all the data
func (ftw *FaultTolerantHdfsWriter) Flush() error {
// TODO: implement fault tolerance
return ftw.Impl.Flush()
}
// Closes the stream
func (ftw *FaultTolerantHdfsWriter) Truncate() error {
// TODO: implement fault tolerance
return ftw.Impl.Truncate()
}
// Truncate the HDFS file at a given position
func (ftw *FaultTolerantHdfsWriter) Close() error {
// TODO: implement fault tolerance
return ftw.Impl.Close()
}