当前位置: 首页>>代码示例>>Java>>正文


Java FBUtilities.resourceToFile方法代码示例

本文整理汇总了Java中org.apache.cassandra.utils.FBUtilities.resourceToFile方法的典型用法代码示例。如果您正苦于以下问题:Java FBUtilities.resourceToFile方法的具体用法?Java FBUtilities.resourceToFile怎么用?Java FBUtilities.resourceToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.utils.FBUtilities的用法示例。


在下文中一共展示了FBUtilities.resourceToFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PropertyFileSnitch

import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
public PropertyFileSnitch() throws ConfigurationException
{
    reloadConfiguration();

    try
    {
        FBUtilities.resourceToFile(SNITCH_PROPERTIES_FILENAME);
        Runnable runnable = new WrappedRunnable()
        {
            protected void runMayThrow() throws ConfigurationException
            {
                reloadConfiguration();
            }
        };
        ResourceWatcher.watch(SNITCH_PROPERTIES_FILENAME, runnable, 60 * 1000);
    }
    catch (ConfigurationException ex)
    {
        logger.error("{} found, but does not look like a plain file. Will not watch it for changes", SNITCH_PROPERTIES_FILENAME);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:PropertyFileSnitch.java

示例2: PropertyFileSnitch

import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
public PropertyFileSnitch() throws ConfigurationException
{
    reloadConfiguration();

    try
    {
        FBUtilities.resourceToFile(SNITCH_PROPERTIES_FILENAME);
        Runnable runnable = new WrappedRunnable()
        {
            protected void runMayThrow() throws ConfigurationException
            {
                reloadConfiguration();
            }
        };
        ResourceWatcher.watch(SNITCH_PROPERTIES_FILENAME, runnable, 60 * 1000);
    }
    catch (ConfigurationException ex)
    {
        logger.debug(SNITCH_PROPERTIES_FILENAME + " found, but does not look like a plain file. Will not watch it for changes");
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:PropertyFileSnitch.java

示例3: PropertyFileSnitch

import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
public PropertyFileSnitch(int refreshPeriodInSeconds) throws ConfigurationException
{
    reloadConfiguration(false);

    try
    {
        FBUtilities.resourceToFile(SNITCH_PROPERTIES_FILENAME);
        Runnable runnable = new WrappedRunnable()
        {
            protected void runMayThrow() throws ConfigurationException
            {
                reloadConfiguration(true);
            }
        };
        ResourceWatcher.watch(SNITCH_PROPERTIES_FILENAME, runnable, refreshPeriodInSeconds * 1000);
    }
    catch (ConfigurationException ex)
    {
        logger.error("{} found, but does not look like a plain file. Will not watch it for changes", SNITCH_PROPERTIES_FILENAME);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:PropertyFileSnitch.java

示例4: GossipingPropertyFileSnitch

import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
public GossipingPropertyFileSnitch(int refreshPeriodInSeconds) throws ConfigurationException
{
    snitchHelperReference = new AtomicReference<ReconnectableSnitchHelper>();

    reloadConfiguration();

    try
    {
        psnitch = new PropertyFileSnitch();
        logger.info("Loaded {} for compatibility", PropertyFileSnitch.SNITCH_PROPERTIES_FILENAME);
    }
    catch (ConfigurationException e)
    {
        logger.info("Unable to load {}; compatibility mode disabled", PropertyFileSnitch.SNITCH_PROPERTIES_FILENAME);
    }

    try
    {
        FBUtilities.resourceToFile(SnitchProperties.RACKDC_PROPERTY_FILENAME);
        Runnable runnable = new WrappedRunnable()
        {
            protected void runMayThrow() throws ConfigurationException
            {
                reloadConfiguration();
            }
        };
        ResourceWatcher.watch(SnitchProperties.RACKDC_PROPERTY_FILENAME, runnable, refreshPeriodInSeconds * 1000);
    }
    catch (ConfigurationException ex)
    {
        logger.error("{} found, but does not look like a plain file. Will not watch it for changes", SnitchProperties.RACKDC_PROPERTY_FILENAME);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:34,代码来源:GossipingPropertyFileSnitch.java

示例5: YamlFileNetworkTopologySnitch

import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param topologyConfigFilename
 *            name of the topology configuration file
 * @throws ConfigurationException
 *             on failure
 */
YamlFileNetworkTopologySnitch(final String topologyConfigFilename)
        throws ConfigurationException
{
    logger.warn("YamlFileNetworkTopologySnitch is deprecated; switch to GossipingPropertyFileSnitch instead");
    this.topologyConfigFilename = topologyConfigFilename;
    loadTopologyConfiguration();

    try
    {
        /*
         * Check if the topology configuration file is a plain file.
         */
        FBUtilities.resourceToFile(topologyConfigFilename);

        final Runnable runnable = new WrappedRunnable()
        {
            /**
             * Loads the topology.
             */
            protected void runMayThrow() throws ConfigurationException
            {
                loadTopologyConfiguration();
            }
        };
        ResourceWatcher.watch(topologyConfigFilename, runnable,
                CHECK_PERIOD_IN_MS);
    }
    catch (final ConfigurationException e)
    {
        logger.debug(
                "{} found, but does not look like a plain file. Will not watch it for changes",
                topologyConfigFilename);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:43,代码来源:YamlFileNetworkTopologySnitch.java

示例6: testAutoReloadConfig

import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void testAutoReloadConfig() throws Exception
{
    String confFile = FBUtilities.resourceToFile(SnitchProperties.RACKDC_PROPERTY_FILENAME);
    
    final GossipingPropertyFileSnitch snitch = new GossipingPropertyFileSnitch(/*refreshPeriodInSeconds*/1);
    YamlFileNetworkTopologySnitchTest.checkEndpoint(snitch, FBUtilities.getBroadcastAddress().getHostAddress(), "DC1", "RAC1");

    final Path effectiveFile = Paths.get(confFile);
    final Path backupFile = Paths.get(confFile + ".bak");
    final Path modifiedFile = Paths.get(confFile + ".mod");
    
    try
    {
        Files.copy(effectiveFile, backupFile);
        Files.copy(modifiedFile, effectiveFile, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
        
        Thread.sleep(1500);
        
        YamlFileNetworkTopologySnitchTest.checkEndpoint(snitch, FBUtilities.getBroadcastAddress().getHostAddress(), "DC2", "RAC2");
    }
    finally
    {
        Files.copy(backupFile, effectiveFile, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
        Files.delete(backupFile);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:28,代码来源:GossipingPropertyFileSnitchTest.java

示例7: YamlFileNetworkTopologySnitch

import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param topologyConfigFilename
 *            name of the topology configuration file
 * @throws ConfigurationException
 *             on failure
 */
YamlFileNetworkTopologySnitch(final String topologyConfigFilename)
        throws ConfigurationException
{
    this.topologyConfigFilename = topologyConfigFilename;
    loadTopologyConfiguration();

    try
    {
        /*
         * Check if the topology configuration file is a plain file.
         */
        FBUtilities.resourceToFile(topologyConfigFilename);

        final Runnable runnable = new WrappedRunnable()
        {
            /**
             * Loads the topology.
             */
            protected void runMayThrow() throws ConfigurationException
            {
                loadTopologyConfiguration();
            }
        };
        ResourceWatcher.watch(topologyConfigFilename, runnable,
                CHECK_PERIOD_IN_MS);
    }
    catch (final ConfigurationException e)
    {
        logger.debug(
                "{} found, but does not look like a plain file. Will not watch it for changes",
                topologyConfigFilename);
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:42,代码来源:YamlFileNetworkTopologySnitch.java

示例8: setup

import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Before
public void setup() throws ConfigurationException, IOException
{
    String confFile = FBUtilities.resourceToFile(PropertyFileSnitch.SNITCH_PROPERTIES_FILENAME);
    effectiveFile = Paths.get(confFile);
    backupFile = Paths.get(confFile + ".bak");

    restoreOrigConfigFile();

    InetAddress[] hosts = {
        InetAddress.getByName("127.0.0.1"), // this exists in the config file
        InetAddress.getByName("127.0.0.2"), // this exists in the config file
        InetAddress.getByName("127.0.0.9"), // this does not exist in the config file
    };

    IPartitioner partitioner = new RandomPartitioner();
    valueFactory = new VersionedValue.VersionedValueFactory(partitioner);
    tokenMap = new HashMap<>();

    for (InetAddress host : hosts)
    {
        Set<Token> tokens = Collections.singleton(partitioner.getRandomToken());
        Gossiper.instance.initializeNodeUnsafe(host, UUID.randomUUID(), 1);
        Gossiper.instance.injectApplicationState(host, ApplicationState.TOKENS, valueFactory.tokens(tokens));

        setNodeShutdown(host);
        tokenMap.put(host, tokens);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:30,代码来源:PropertyFileSnitchTest.java


注:本文中的org.apache.cassandra.utils.FBUtilities.resourceToFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。