本文整理汇总了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);
}
}
示例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");
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}