本文整理汇总了Java中org.apache.cassandra.io.util.FileUtils.close方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.close方法的具体用法?Java FileUtils.close怎么用?Java FileUtils.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.io.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gceApiCall
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
String gceApiCall(String url) throws IOException, ConfigurationException
{
// Populate the region and zone by introspection, fail if 404 on metadata
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
DataInputStream d = null;
try
{
conn.setRequestMethod("GET");
conn.setRequestProperty("Metadata-Flavor", "Google");
if (conn.getResponseCode() != 200)
throw new ConfigurationException("GoogleCloudSnitch was unable to execute the API call. Not a gce node?");
// Read the information.
int cl = conn.getContentLength();
byte[] b = new byte[cl];
d = new DataInputStream((FilterInputStream) conn.getContent());
d.readFully(b);
return new String(b, StandardCharsets.UTF_8);
}
finally
{
FileUtils.close(d);
conn.disconnect();
}
}
示例2: awsApiCall
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
String awsApiCall(String url) throws IOException, ConfigurationException
{
// Populate the region and zone by introspection, fail if 404 on metadata
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
DataInputStream d = null;
try
{
conn.setRequestMethod("GET");
if (conn.getResponseCode() != 200)
throw new ConfigurationException("Ec2Snitch was unable to execute the API call. Not an ec2 node?");
// Read the information. I wish I could say (String) conn.getContent() here...
int cl = conn.getContentLength();
byte[] b = new byte[cl];
d = new DataInputStream((FilterInputStream) conn.getContent());
d.readFully(b);
return new String(b, StandardCharsets.UTF_8);
}
finally
{
FileUtils.close(d);
conn.disconnect();
}
}
示例3: awsApiCall
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
String awsApiCall(String url) throws IOException, ConfigurationException
{
// Populate the region and zone by introspection, fail if 404 on metadata
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
DataInputStream d = null;
try
{
conn.setRequestMethod("GET");
if (conn.getResponseCode() != 200)
throw new ConfigurationException("Ec2Snitch was unable to execute the API call. Not an ec2 node?");
// Read the information. I wish I could say (String) conn.getContent() here...
int cl = conn.getContentLength();
byte[] b = new byte[cl];
d = new DataInputStream((FilterInputStream) conn.getContent());
d.readFully(b);
return new String(b, Charsets.UTF_8);
}
finally
{
FileUtils.close(d);
conn.disconnect();
}
}
示例4: close
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public void close()
{
try
{
sstable.close();
if (isClosed.compareAndSet(false, true))
FileUtils.close(dfile, ifile);
}
catch (IOException e)
{
sstable.markSuspect();
throw new CorruptSSTableException(e, sstable.getFilename());
}
}
示例5: csQueryMetadata
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
String csQueryMetadata(String url) throws ConfigurationException, IOException
{
HttpURLConnection conn = null;
DataInputStream is = null;
try
{
conn = (HttpURLConnection) new URL(url).openConnection();
}
catch (Exception e)
{
throw new ConfigurationException("CloudstackSnitch cannot query wrong metadata URL: " + url);
}
try
{
conn.setRequestMethod("GET");
if (conn.getResponseCode() != 200)
{
throw new ConfigurationException("CloudstackSnitch was unable to query metadata.");
}
int cl = conn.getContentLength();
byte[] b = new byte[cl];
is = new DataInputStream(new BufferedInputStream(conn.getInputStream()));
is.readFully(b);
return new String(b, StandardCharsets.UTF_8);
}
finally
{
FileUtils.close(is);
conn.disconnect();
}
}
示例6: close
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public void close()
{
try
{
if (isClosed.compareAndSet(false, true))
FileUtils.close(dfile, ifile);
}
catch (IOException e)
{
sstable.markSuspect();
throw new CorruptSSTableException(e, sstable.getFilename());
}
}
示例7: close
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public void close() throws IOException
{
FileUtils.close(dfile, ifile);
}