本文整理汇总了Java中org.apache.felix.service.command.Descriptor类的典型用法代码示例。如果您正苦于以下问题:Java Descriptor类的具体用法?Java Descriptor怎么用?Java Descriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Descriptor类属于org.apache.felix.service.command包,在下文中一共展示了Descriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: log
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor("Show the contents of the log")
public List<String> log(
//
@Descriptor("Reverse the printout order to oldest is last") @Parameter(names = { "-r",
"--reverse" }, absentValue = "true", presentValue = "false") boolean reverse, //
@Descriptor("Skip the first entries") @Parameter(names = { "-s", "--skip" }, absentValue = "0") int skip, //
@Descriptor("Maximum number of entries to print") @Parameter(names = { "-m",
"--max" }, absentValue = "100") int maxEntries, //
@Descriptor("Minimum level (error,warning,info,debug). Default is warning.") @Parameter(names = { "-l",
"--level" }, absentValue = "warning") String level, //
@Descriptor("Print style (classic,abbr)") @Parameter(names = { "-y",
"--style" }, absentValue = "classic") String style, //
@Descriptor("Do not print exceptions.") @Parameter(names = { "-n",
"--noexceptions" }, absentValue = "false", presentValue = "true") boolean noExceptions //
) {
return logTracker.log(maxEntries, skip, LogTracker.Level.valueOf(level), reverse, noExceptions,
LogTracker.Style.valueOf(style));
}
示例2: remove
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor ( "Remove storage by id" )
public void remove ( final String[] args )
{
final String usage = "Usage: remove [--force] id1 [id2 [id3]]";
if ( args.length <= 0 )
{
System.out.println ( usage );
return;
}
boolean force = false;
for ( final String id : args )
{
if ( "--force".equals ( id ) )
{
force = true;
}
else
{
System.out.println ( String.format ( "Removing storage '%s' ...", id ) );
System.out.flush ();
removeById ( id, force );
System.out.println ( String.format ( "Removing storage '%s' ... done!", id ) );
}
}
}
示例3: showfactories
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor ( "Show full factories information" )
public void showfactories ()
{
final Factory[] factories = this.admin.getKnownFactories ();
Arrays.sort ( factories, FACTORY_ID_COMPARATOR );
final List<List<String>> data = new LinkedList<List<String>> ();
for ( final Factory factory : factories )
{
final List<String> row = new LinkedList<String> ();
row.add ( factory.getId () );
row.add ( factory.getState ().toString () );
row.add ( factory.getDescription () );
data.add ( row );
}
Tables.showTable ( System.out, Arrays.asList ( "ID", "State", "Description" ), data, 2 );
}
示例4: show
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor ( "Show configuration" )
public void show ( @Descriptor ( "The factory id" )
final String factoryId, @Descriptor ( "The configuration id" )
final String configurationId)
{
final Configuration cfg = this.admin.getConfiguration ( factoryId, configurationId );
if ( cfg == null )
{
System.out.println ( String.format ( "Configuration %s/%s does not exists", factoryId, configurationId ) );
}
else
{
System.out.format ( "%s - %s - %s%n", cfg.getFactoryId (), cfg.getId (), cfg.getState () );
for ( final Map.Entry<String, String> entry : cfg.getData ().entrySet () )
{
System.out.format ( "\t'%s' => '%s'%n", entry.getKey (), entry.getValue () );
}
if ( cfg.getErrorInformation () != null )
{
cfg.getErrorInformation ().printStackTrace ( System.out );
}
}
}
示例5: list
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor ( "List installed addons" )
public void list ()
{
final List<Addon> result = this.addonManager.list ();
final List<String> header = Arrays.asList ( "ID", "Name", "Version", "State", "Label", "Error" );
final List<List<String>> data = new ArrayList<> ( result.size () );
for ( final Addon addon : result )
{
final List<String> row = new ArrayList<> ( 6 );
data.add ( row );
row.add ( addon.getId () );
row.add ( addon.getInformation ().getDescription ().getId () );
row.add ( addon.getInformation ().getDescription ().getVersion ().toString () );
row.add ( addon.getInformation ().getState ().toString () );
row.add ( addon.getInformation ().getDescription ().getLabel () );
if ( addon.getInformation ().getError () != null )
{
row.add ( ExceptionHelper.getMessage ( addon.getInformation ().getError () ).replace ( "\n", " " ).replace ( "\r", "" ) );
}
}
Tables.showTable ( System.out, header, data, 2 );
}
示例6: deploy
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor("Deploy a neural network on a runtime and load weights with specific tag.")
public void deploy(
@Descriptor("name of the neural network")
String name,
@Descriptor("uuid of the target runtime")
String id,
@Descriptor("tag of the weights to load")
String tag){
NeuralNetworkInstanceDTO nn = deploy(name, UUID.fromString(id));
// load parameters with tag
loadParameters(nn, tag);
// add updatelistener for tag
addRepositoryListener(nn, tag);
}
示例7: bptt
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor("Train a recurrent neural network using the Back Propagation Through Time Learning strategy")
public void bptt(String nnName, String dataset, String... properties){
final Map<String, String> defaults = new HashMap<>();
defaults.put("strategy", "be.iminds.iot.dianne.rnn.learn.strategy.BPTTLearningStrategy");
Map<String, String> config = createConfig(defaults, properties);
coordinator.learn(dataset, config, nnName.split(",")).then(p -> {
System.out.println("Learn Job done!");
LearnResult result = p.getValue();
System.out.println("Iterations: "+result.getIterations());
System.out.println("Last minibatch loss: "+result.getLoss());
return null;
}, p -> {
System.out.println("Learn Job failed: "+p.getFailure().getMessage());
p.getFailure().printStackTrace();
});
}
示例8: forward
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor("Forward a dataset sample through a neural network instance.")
public void forward(
@Descriptor("dataset name to fetch a sample from")
String dataset,
@Descriptor("index of the neural network instance (from the list command output)")
int index,
@Descriptor("index of dataset sample")
int sample,
@Descriptor("(optional) tags to attach to the forward call ")
String... tags){
List<NeuralNetworkInstanceDTO> nns = platform.getNeuralNetworkInstances();
if(index >= nns.size()){
System.out.println("No neural network deployed with index "+index);
return;
}
String id = nns.get(index).id.toString();
forward(dataset, id, sample, tags);
}
示例9: sample
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor("Print out samples of the dataset")
public void sample(
@Descriptor("dataset name to fetch a sample from")
String dataset,
@Descriptor("start index")
int start,
@Descriptor("end index")
int end){
Dataset d = datasets.getDataset(dataset);
if(d==null){
System.out.println("Dataset "+dataset+" not available");
return;
}
for(int index=start;index<end;index++)
System.out.println("["+index+"] "+d.getSample(index).toString());
}
示例10: batch
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor("Print out a batch of the dataset")
public void batch(
@Descriptor("dataset name to fetch a sample from")
String dataset,
@Descriptor("start index")
int start,
@Descriptor("end index")
int end){
Dataset d = datasets.getDataset(dataset);
if(d==null){
System.out.println("Dataset "+dataset+" not available");
return;
}
int[] indices = new int[end-start];
for(int i=0;i<indices.length;i++) {
indices[i] = start + i;
}
System.out.println(d.getBatch(indices));
}
示例11: sequences
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor("Print out the number of sequences of the dataset")
public void sequences(
@Descriptor("dataset get the number of sequences from")
String dataset){
Dataset d = datasets.getDataset(dataset);
if(d==null){
System.out.println("Dataset "+dataset+" not available");
return;
}
if(!(d instanceof SequenceDataset)){
System.out.println("Dataset "+dataset+" is not a sequence dataset");
return;
}
System.out.println(((SequenceDataset<?, ?>)d).sequences());
}
示例12: classes
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor("Print out the classes and number of samples per class")
public void classes(
@Descriptor("dataset get the classes from")
String dataset){
Dataset d = datasets.getDataset(dataset);
if(d==null){
System.out.println("Dataset "+dataset+" not available");
return;
}
Tensor count = new Tensor(d.targetDims());
count.fill(0.0f);
int samples = d.size();
for(int i=0;i<samples;i++){
Sample s = d.getSample(i);
count = TensorOps.add(count, count, s.target);
}
String[] labels = d.getLabels();
if(labels!=null){
System.out.println(Arrays.toString(labels));
}
System.out.println(Arrays.toString(count.get()));
}
示例13: dump
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor("Dump the content of an experience pool")
public void dump(
@Descriptor("The experience pool to dump")
String dataset){
Dataset d = datasets.getDataset(dataset);
if(d==null){
System.out.println("Dataset "+dataset+" not available");
return;
}
if(!datasets.isExperiencePool(dataset)){
System.out.println("Dataset "+dataset+" is not an experience pool");
return;
}
try {
d.getClass().getMethod("dump").invoke(d);
} catch(Throwable t){
t.printStackTrace();
}
}
示例14: clear
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor("Clear an experience pool")
public void clear(
@Descriptor("The experience pool to dump")
String dataset){
Dataset d = datasets.getDataset(dataset);
if(d==null){
System.out.println("Dataset "+dataset+" not available");
return;
}
if(!datasets.isExperiencePool(dataset)){
System.out.println("Dataset "+dataset+" is not an experience pool");
return;
}
try {
d.getClass().getMethod("reset").invoke(d);
} catch(Throwable t){
t.printStackTrace();
}
}
示例15: delete
import org.apache.felix.service.command.Descriptor; //导入依赖的package包/类
@Descriptor("delete a Resource")
public void delete(@Descriptor("delete") String... handleId) throws ResourceNotFoundException, IllegalActionOnResourceException {
String bufferOut = new String();
try {
String path;
if (handleId.length == 0) {
bufferOut = bufferOut + "Error : Must have at least 1 argument \n";
} else {
for (String current : handleId) {
path = current;
m_everestClient.delete(path);
bufferOut = bufferOut + "Success : The resource at " + path + " have been destroy\n";
}
}
} catch (Exception e) {
System.out.println(bufferOut);
e.printStackTrace();
bufferOut = null;
}
System.out.println(bufferOut);
}