mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-18 06:00:25 +08:00
add mgmt: Command
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
package mgmt;
|
||||
|
||||
import component.ComponentException;
|
||||
import component.Identifier;
|
||||
import component.IdentifierComponent;
|
||||
import encoding.Encoder;
|
||||
import encoding.EncoderException;
|
||||
import encoding.SizeT;
|
||||
import packet.Interest;
|
||||
|
||||
/*
|
||||
@@ -10,9 +16,33 @@ import packet.Interest;
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class Command {
|
||||
public static Interest CreateCommandIdentifierInterest(){
|
||||
Interest interest=new Interest();
|
||||
// ...
|
||||
return interest;
|
||||
/**
|
||||
* 根据传入的控制参数和前缀创建一个命令兴趣包
|
||||
*
|
||||
* @param parameters 控制参数
|
||||
* @param prefix 前缀 /min-mir/mgmt/localhost
|
||||
* @return
|
||||
*/
|
||||
public static Interest createCommandIdentifierInterest(ControlParameters parameters, String prefix) throws MgmtException {
|
||||
try {
|
||||
// /min-mir/mgmt/localhop/<模块名称>/<命令>/<参数>/[版本号]/[分片号]
|
||||
Interest interest = new Interest();
|
||||
Identifier commandIdentifier = new Identifier(prefix);
|
||||
|
||||
Encoder encoder=new Encoder();
|
||||
if(!encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0))){
|
||||
throw new MgmtException("Command.createCommandIdentifierInterest: encoder reset error.");
|
||||
}
|
||||
if(parameters.wireEncode(encoder)<0){
|
||||
throw new MgmtException("Command.createCommandIdentifierInterest: wireEncode error.");
|
||||
}
|
||||
byte[] controlParametersbuf=encoder.getBuffer();
|
||||
commandIdentifier.append(new IdentifierComponent(controlParametersbuf));
|
||||
interest.setName(commandIdentifier);
|
||||
|
||||
return interest;
|
||||
} catch (ComponentException | EncoderException e) {
|
||||
throw new MgmtException("Command.createCommandIdentifierInterest: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user