java.util.concurrent.Semaphore.toString()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中java.util.concurrent.Semaphore.toString()方法的一些代码示例,展示了Semaphore.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Semaphore.toString()方法的具体详情如下:
包路径:java.util.concurrent.Semaphore
类名称:Semaphore
方法名:toString

Semaphore.toString介绍

[英]Returns a string identifying this semaphore, as well as its state. The state, in brackets, includes the String "Permits ="followed by the number of permits.
[中]返回标识此信号量及其状态的字符串。括号中的州包括字符串“permissions=”后跟许可证数量。

代码示例

代码示例来源:origin: org.fusesource.rrd4j/rrd4j

@Override
  public String toString() {
    return "Capacity semaphore: " + super.toString();
  }            
};

代码示例来源:origin: io.brooklyn/brooklyn-core

@Override
public synchronized String toString() {
  return super.toString()+"["+name+"; description="+description+"; owning="+owningThreads+"; requesting="+requestingThreads+"]";
}

代码示例来源:origin: org.fusesource.rrd4j/rrd4j

@Override
  public String toString() {
    return "Capacity semaphore: " + super.toString();
  }            
};

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override
public synchronized String toString() {
  return super.toString()+"["+name+"; description="+description+"; owning="+owningThreads+"; requesting="+requestingThreads+"]";
}

代码示例来源:origin: com.strapdata.elasticsearch.test/framework

@Before
@Override
public void setUp() throws Exception {
  logger.info("[{}#{}]: acquiring semaphore ={}", getTestClass().getSimpleName(), getTestName(), testMutex.toString());
  testMutex.acquireUninterruptibly();
  super.setUp();
  // Create the node lazily, on the first test. This is ok because we do not randomize any settings,
  // only the cluster name. This allows us to have overridden properties for plugins and the version to use.
  if (ElassandraDaemon.instance.node() == null) {
    //the seed has to be created regardless of whether it will be used or not, for repeatability
    long seed = random().nextLong();
    startNode(seed);
  }
}

代码示例来源:origin: com.strapdata.elasticsearch.test/framework

@After
@Override
public void tearDown() throws Exception {
  logger.info("[{}#{}]: cleaning up after test", getTestClass().getSimpleName(), getTestName());
  try {
    DeleteIndexRequestBuilder builder = ElassandraDaemon.instance.node().client().admin().indices().prepareDelete("*");
    assertAcked(builder.get());
    MetaData metaData = client().admin().cluster().prepareState().get().getState().getMetaData();
    assertThat("test leaves persistent cluster metadata behind: " + metaData.persistentSettings().getAsGroups(),
        metaData.persistentSettings().size(), equalTo(0));
    assertThat("test leaves transient cluster metadata behind: " + metaData.transientSettings().getAsGroups(),
        metaData.transientSettings().size(), equalTo(0));
    List<String> userKeyspaces = Schema.instance.getUserKeyspaces();
    userKeyspaces.remove(this.clusterService().getElasticAdminKeyspaceName());
    assertThat("test leaves a user keyspace behind:" + userKeyspaces, userKeyspaces.size(), equalTo(0));
  } catch(Exception e) {
    logger.warn("[{}#{}]: failed to clean indices and metadata: error="+e, getTestClass().getSimpleName(), getTestName());
  } finally {
    testMutex.release();
    logger.info("[{}#{}]: released semaphore={}", getTestClass().getSimpleName(), getTestName(), testMutex.toString());
  }
  super.tearDown();
}

相关文章