@ -44,10 +44,16 @@ type SyncOptions struct {
aProxyByFiler * bool
aProxyByFiler * bool
bProxyByFiler * bool
bProxyByFiler * bool
metricsHttpPort * int
metricsHttpPort * int
concurrency * int
clientId int32
clientId int32
clientEpoch int32
clientEpoch int32
}
}
const (
SyncKeyPrefix = "sync."
DefaultConcurrcyLimit = 32
)
var (
var (
syncOptions SyncOptions
syncOptions SyncOptions
syncCpuProfile * string
syncCpuProfile * string
@ -77,6 +83,7 @@ func init() {
syncOptions . bDebug = cmdFilerSynchronize . Flag . Bool ( "b.debug" , false , "debug mode to print out filer B received files" )
syncOptions . bDebug = cmdFilerSynchronize . Flag . Bool ( "b.debug" , false , "debug mode to print out filer B received files" )
syncOptions . aFromTsMs = cmdFilerSynchronize . Flag . Int64 ( "a.fromTsMs" , 0 , "synchronization from timestamp on filer A. The unit is millisecond" )
syncOptions . aFromTsMs = cmdFilerSynchronize . Flag . Int64 ( "a.fromTsMs" , 0 , "synchronization from timestamp on filer A. The unit is millisecond" )
syncOptions . bFromTsMs = cmdFilerSynchronize . Flag . Int64 ( "b.fromTsMs" , 0 , "synchronization from timestamp on filer B. The unit is millisecond" )
syncOptions . bFromTsMs = cmdFilerSynchronize . Flag . Int64 ( "b.fromTsMs" , 0 , "synchronization from timestamp on filer B. The unit is millisecond" )
syncOptions . concurrency = cmdFilerSynchronize . Flag . Int ( "concurrency" , DefaultConcurrcyLimit , "The maximum number of files that will be synced concurrently." )
syncCpuProfile = cmdFilerSynchronize . Flag . String ( "cpuprofile" , "" , "cpu profile output file" )
syncCpuProfile = cmdFilerSynchronize . Flag . String ( "cpuprofile" , "" , "cpu profile output file" )
syncMemProfile = cmdFilerSynchronize . Flag . String ( "memprofile" , "" , "memory profile output file" )
syncMemProfile = cmdFilerSynchronize . Flag . String ( "memprofile" , "" , "memory profile output file" )
syncOptions . metricsHttpPort = cmdFilerSynchronize . Flag . Int ( "metricsPort" , 0 , "metrics listen port" )
syncOptions . metricsHttpPort = cmdFilerSynchronize . Flag . Int ( "metricsPort" , 0 , "metrics listen port" )
@ -153,6 +160,7 @@ func runFilerSynchronize(cmd *Command, args []string) bool {
* syncOptions . bProxyByFiler ,
* syncOptions . bProxyByFiler ,
* syncOptions . bDiskType ,
* syncOptions . bDiskType ,
* syncOptions . bDebug ,
* syncOptions . bDebug ,
* syncOptions . concurrency ,
aFilerSignature ,
aFilerSignature ,
bFilerSignature )
bFilerSignature )
if err != nil {
if err != nil {
@ -189,6 +197,7 @@ func runFilerSynchronize(cmd *Command, args []string) bool {
* syncOptions . aProxyByFiler ,
* syncOptions . aProxyByFiler ,
* syncOptions . aDiskType ,
* syncOptions . aDiskType ,
* syncOptions . aDebug ,
* syncOptions . aDebug ,
* syncOptions . concurrency ,
bFilerSignature ,
bFilerSignature ,
aFilerSignature )
aFilerSignature )
if err != nil {
if err != nil {
@ -221,7 +230,7 @@ func initOffsetFromTsMs(grpcDialOption grpc.DialOption, targetFiler pb.ServerAdd
}
}
func doSubscribeFilerMetaChanges ( clientId int32 , clientEpoch int32 , grpcDialOption grpc . DialOption , sourceFiler pb . ServerAddress , sourcePath string , sourceExcludePaths [ ] string , sourceReadChunkFromFiler bool , targetFiler pb . ServerAddress , targetPath string ,
func doSubscribeFilerMetaChanges ( clientId int32 , clientEpoch int32 , grpcDialOption grpc . DialOption , sourceFiler pb . ServerAddress , sourcePath string , sourceExcludePaths [ ] string , sourceReadChunkFromFiler bool , targetFiler pb . ServerAddress , targetPath string ,
replicationStr , collection string , ttlSec int , sinkWriteChunkByFiler bool , diskType string , debug bool , sourceFilerSignature int32 , targetFilerSignature int32 ) error {
replicationStr , collection string , ttlSec int , sinkWriteChunkByFiler bool , diskType string , debug bool , concurrency int , sourceFilerSignature int32 , targetFilerSignature int32 ) error {
// if first time, start from now
// if first time, start from now
// if has previously synced, resume from that point of time
// if has previously synced, resume from that point of time
@ -251,7 +260,12 @@ func doSubscribeFilerMetaChanges(clientId int32, clientEpoch int32, grpcDialOpti
}
}
return persistEventFn ( resp )
return persistEventFn ( resp )
}
}
processor := NewMetadataProcessor ( processEventFn , 128 )
if concurrency < 0 || concurrency > 1024 {
glog . Warningf ( "invalid concurrency value, using default: %d" , DefaultConcurrcyLimit )
concurrency = DefaultConcurrcyLimit
}
processor := NewMetadataProcessor ( processEventFn , concurrency )
var lastLogTsNs = time . Now ( ) . UnixNano ( )
var lastLogTsNs = time . Now ( ) . UnixNano ( )
var clientName = fmt . Sprintf ( "syncFrom_%s_To_%s" , string ( sourceFiler ) , string ( targetFiler ) )
var clientName = fmt . Sprintf ( "syncFrom_%s_To_%s" , string ( sourceFiler ) , string ( targetFiler ) )
@ -276,10 +290,6 @@ func doSubscribeFilerMetaChanges(clientId int32, clientEpoch int32, grpcDialOpti
}
}
const (
SyncKeyPrefix = "sync."
)
// When each business is distinguished according to path, and offsets need to be maintained separately.
// When each business is distinguished according to path, and offsets need to be maintained separately.
func getSignaturePrefixByPath ( path string ) string {
func getSignaturePrefixByPath ( path string ) string {
// compatible historical version
// compatible historical version