-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jiang jianfeng
committed
Jul 21, 2017
1 parent
d85c92e
commit 61be86b
Showing
9 changed files
with
187 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
package io.mybear.tracker; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* Created by jamie on 2017/6/21. | ||
*/ | ||
public class TrackerGlobal { | ||
public static final int DEFAULT_SERVER_PORT = 22122; | ||
|
||
public static Date gUpTime = new Date(0l); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/io/mybear/tracker/command/StorageJoinCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.mybear.tracker.command; | ||
|
||
import io.mybear.common.ErrorNo; | ||
import io.mybear.common.constants.CommonConstant; | ||
import io.mybear.net2.tracker.TrackerConnection; | ||
import io.mybear.net2.tracker.TrackerMessage; | ||
import io.mybear.tracker.types.FdfsStorageJoinBody; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class StorageJoinCommand extends TrackerCommand { | ||
private static final Logger logger = LoggerFactory.getLogger(StorageJoinCommand.class); | ||
|
||
// 具体数值待定 | ||
public static final int STORAGE_JOIN_PACKET_LENGTH = 348; | ||
|
||
@Override | ||
public void handle(TrackerConnection conn, TrackerMessage message) { | ||
logger.debug("deal with storage join"); | ||
|
||
byte state = 0; | ||
if(message.getPkgLen() < STORAGE_JOIN_PACKET_LENGTH){ | ||
logger.error("cmd={}, client ip: {}, package size {} is not correct, expect length >= {}" | ||
, message.getCmd(), conn.getHost(), message.getPkgLen(), STORAGE_JOIN_PACKET_LENGTH); | ||
state = ErrorNo.EINVAL; | ||
} | ||
|
||
FdfsStorageJoinBody joinBody = new FdfsStorageJoinBody(); | ||
joinBody.setTrackerCount(message.readLong()); | ||
if(joinBody.getTrackerCount() <= 0 || joinBody.getTrackerCount() > CommonConstant.FDFS_MAX_TRACKERS){ | ||
logger.error("cmd={}, client ip: {}, tracker count {} is invalid, it <= 0 or > {}" | ||
, message.getCmd(), conn.getHost(), joinBody.getTrackerCount(), CommonConstant.FDFS_MAX_TRACKERS); | ||
state = ErrorNo.EINVAL; | ||
} | ||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
src/main/java/io/mybear/tracker/types/FdfsStorageJoinBody.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package io.mybear.tracker.types; | ||
|
||
import io.mybear.common.constants.CommonConstant; | ||
|
||
public class FdfsStorageJoinBody { | ||
private int storagePort; | ||
private int storageHttpPort; | ||
private int storePathCount; | ||
private int subdirCountPerPath; | ||
private int uploadPriority; | ||
private int joinTime; | ||
private int upTime; | ||
|
||
private byte[] version = new byte[CommonConstant.FDFS_VERSION_SIZE]; | ||
private byte[] groupName = new byte[CommonConstant.FDFS_GROUP_NAME_MAX_LEN + 1]; | ||
private byte[] domainName = new byte[CommonConstant.FDFS_DOMAIN_NAME_MAX_SIZE]; | ||
|
||
private byte initFlag; | ||
private byte state; | ||
private long trackerCount; | ||
|
||
public int getStoragePort() { | ||
return storagePort; | ||
} | ||
|
||
public void setStoragePort(int storagePort) { | ||
this.storagePort = storagePort; | ||
} | ||
|
||
public int getStorageHttpPort() { | ||
return storageHttpPort; | ||
} | ||
|
||
public void setStorageHttpPort(int storageHttpPort) { | ||
this.storageHttpPort = storageHttpPort; | ||
} | ||
|
||
public int getStorePathCount() { | ||
return storePathCount; | ||
} | ||
|
||
public void setStorePathCount(int storePathCount) { | ||
this.storePathCount = storePathCount; | ||
} | ||
|
||
public int getSubdirCountPerPath() { | ||
return subdirCountPerPath; | ||
} | ||
|
||
public void setSubdirCountPerPath(int subdirCountPerPath) { | ||
this.subdirCountPerPath = subdirCountPerPath; | ||
} | ||
|
||
public int getUploadPriority() { | ||
return uploadPriority; | ||
} | ||
|
||
public void setUploadPriority(int uploadPriority) { | ||
this.uploadPriority = uploadPriority; | ||
} | ||
|
||
public int getJoinTime() { | ||
return joinTime; | ||
} | ||
|
||
public void setJoinTime(int joinTime) { | ||
this.joinTime = joinTime; | ||
} | ||
|
||
public int getUpTime() { | ||
return upTime; | ||
} | ||
|
||
public void setUpTime(int upTime) { | ||
this.upTime = upTime; | ||
} | ||
|
||
public byte[] getVersion() { | ||
return version; | ||
} | ||
|
||
public byte[] getGroupName() { | ||
return groupName; | ||
} | ||
|
||
public byte[] getDomainName() { | ||
return domainName; | ||
} | ||
|
||
public byte getInitFlag() { | ||
return initFlag; | ||
} | ||
|
||
public void setInitFlag(byte initFlag) { | ||
this.initFlag = initFlag; | ||
} | ||
|
||
public byte getState() { | ||
return state; | ||
} | ||
|
||
public void setState(byte state) { | ||
this.state = state; | ||
} | ||
|
||
public long getTrackerCount() { | ||
return trackerCount; | ||
} | ||
|
||
public void setTrackerCount(long trackerCount) { | ||
this.trackerCount = trackerCount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters