- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在 Hadoop 多节点集群 (2.4.1) 上运行 Mapreduce 代码。当我尝试使用大小为 200MB 和 200MB 的 2 个输入文件运行时,出现错误 GC overhead limit exceeded。当我使用非常小的文件时,它运行完美并得到正确的输出。
我的目标是比较第一个文件中的每个流量记录和第二个文件中的每个流量记录并计算距离,然后取 10 个最大值并根据这 10 个最大值输出到 reducer。值(value)观。
两个文件中的示例流记录 - 194.144.0.27|192.168.1.5|0.0.0.0|0|0|2|104|1410985350|1410985350|51915|51413|6|6
几张快照:http://goo.gl/5tUhJJ和 http://goo.gl/lh1Qvm
这是映射器类:
映射器类:
public class mapper extends Mapper<LongWritable, Text, Text, IntWritable>
{
private final static IntWritable five = new IntWritable(5);
private Text counter1;
ArrayList<String> lines = new ArrayList<String>();
String str;
BufferedReader br,in;
int ddos_line = 0;
int normal_line = 0,total_testing_records=4000;
int K = 10;
@Override
protected void setup(Context context) throws IOException, InterruptedException
{
//BufferedReader in = new BufferedReader(new FileReader("normal"));
Configuration conf = context.getConfiguration();
URI[] cachefiles = context.getCacheFiles();
FileSystem fs = FileSystem.get(new Configuration());
FileStatus[] status = fs.listStatus(new Path(cachefiles[0].toString()));
BufferedReader in=new BufferedReader(new InputStreamReader(fs.open(status[0].getPath())));
while((str = in.readLine()) != null)
{
lines.add(str);
}
in.close();
//System.out.println("na netti");
}
@Override
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException
{
String line1 = value.toString();
ddos_line++;
normal_line = 0;
double[] count = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
int[] lineIndex = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
String[] parts = line1.split("\\|");
String[] linesArray = lines.toArray(new String[lines.size()]);
boolean bool = true;
int t1=0;
double sum=0;
while (bool)
{
for(int i=0; i<K;i++)
{
if(bool==false) break;
sum = 0;
String[] parts2 = linesArray[normal_line].split("\\|");
for(int x=0;x<13;x++)
{
if(parts[x].equals(parts2[x]))
{
t1 = 1;
}
else t1 = 0;
sum += t1;
}
sum = Math.sqrt(sum);
if(count[K-1] <= sum)
{
count[K-1] = sum;
lineIndex[K-1]=normal_line;
}
for(int k=0;k<K;k++)
{
for(int j=0;j<K-1;j++)
{
if(count[j] < count[j+1])
{
double temp2 = count[j+1];
count[j+1] = count[j];
count[j] = temp2;
int temp3 = lineIndex[j+1];
lineIndex[j+1] = lineIndex[j];
lineIndex[j] = temp3;
}
}
}
//System.out.println(ddos_line + " " + normal_line);
if (normal_line + 1 < linesArray.length)
{
normal_line++;
continue;
}
else bool = false;
}
} // while end
char[] t = {'d','d','d','d','d','d','d','d','d','d'};
for(int i=0;i<K;i++)
{
if(lineIndex[i] <= total_testing_records/2 ) t[i] = 'n';
}
int counter_normal=0, counter_ddos=0;
for(int i=0;i<K;i++)
{
if(t[i]=='n')
counter_normal++;
else
counter_ddos++;
//System.out.println("t[i]: "+t[i]+", counter: "+counter_ddos);
}
if(counter_normal<=K/2)
{
counter1 = new Text(ddos_line + " : d : "+ counter_ddos);
}
else
{
counter1 = new Text(ddos_line + " : n : "+ (counter_normal));
}
context.write(counter1, five);
//System.out.println("mapper finished");
}
public void run(Context context) throws IOException, InterruptedException
{
setup(context);
while (context.nextKeyValue()) {
map(context.getCurrentKey(), context.getCurrentValue(), context);
}
cleanup(context);
}
}
最佳答案
然后简单地增加任务的内存:
设置
mapred.child.java.opts
在你的工作配置中
-Xmx1024m
或者更多,无论你需要读取这个文件并处理它。
关于java - Hadoop 中的 Mapreduce 在使用超过 200MB 的文件时会超出 GC 开销限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27175278/
我有一个本地存储库,有一个大文件被意外添加到其中。现在,即时通讯几乎落后了100次提交。当我尝试推送到GitHub时,它给了我一个错误。 我需要做任何我需要做的事情,以便能够推送此存储库的其余部分。
我正在尝试分配内存NSImage*originalLocationImage; NSURL *fileURL = [NSURL fileURLWithPath:originalLocation];//
我如何以及在何处可以编辑CDH4.7中的输入拆分大小,默认情况下为64 MB,但我想将其称为1MB,因为我的MR作业运行缓慢并且我想提高MR作业的速度。我想需要编辑cor-site属性IO.file.
我创建了一个 DLL,其中包含一个从 C# 代码调用的 JNI 函数。作为长时间运行的 GUI 应用程序的 C# 应用程序多次调用该函数。 我的 JNI 函数调用 JNI_GetCreatedJava
运行 TestDFSIO 后,我得到了以下指标: 2019-04-30 09:50:35,790 INFO fs.TestDFSIO: Date & time: Tue Apr
我正在测试连接到 Xcode 5.1.1 的运行 iOS 7.1 的 iPhone 4。我不明白为什么当仪器显示我的应用程序仅使用几兆字节并且有大量可用内存时我会收到内存警告甚至崩溃(见附件)。有什么
我有一个假设的值数据库,每个值的大小为 4 个字节(即 4,000,000,000)。所有值都存在于数据库中,因此它以 0 开头,以最大的 4 字节数字结尾。 只有一次,我想通过将 1 到 10000
我有一个字符串元组的 python 列表,格式如下:lst = [('xxx', 'yyy'), ...etc]。该列表包含大约 8154741 个元组。我使用了一个分析器,它说该列表占用大约 500
我需要每秒发送 1,00,000 批记录。我在实验后得到的是 azure event hub 的事件限制为 10,00,000 个字节。我的每条记录有 145 字节,我必须发送的总记录是 1,00,0
HDFS块大小默认为128 MB(来源:https://hadoop.apache.org/docs/r2.9.0/hadoop-project-dist/hadoop-hdfs/hdfs-defau
我需要每秒发送 1,00,000 批记录。我在实验后得到的是 azure event hub 的事件限制为 10,00,000 个字节。我的每条记录有 145 字节,我必须发送的总记录是 1,00,0
我正在 Linux 机器上运行 Jboss EAP 服务器 6.1。分配的堆内存如下。 JAVA_OPTS="-Xms2048m -Xmx2048m -XX:MaxPermSize=256m -Dja
我最近提出并解决了一个关于将大于 2 MB 的 .PDF 文件作为 BLOBS 上传到 MySQL 数据库的问题。我不得不更改我的 php.ini 文件中的一些设置和 MySQL 的最大数据包设置。然
我需要创建一个文本文件(字母数字),其大小(精确或接近)以 MB 为单位等于我输入的数字,例如 1 MB。我试图生成一个字符串,认为一个字符是 16 位或 2 字节,所以:1KB = 1024 字节
我已经阅读了很多有关通过设置 yarn.scheduler.maximum-allocation-mb 来解决此类问题的内容,我已将其设置为 2gb,因为我当前正在运行 select count(*)
这个问题在这里已经有了答案: this exceeds GitHub's file size limit [duplicate] (3 个回答) 1年前关闭。 核心程序崩溃数据。 我不知道核心文件是从
我已经建立了一个 Electron 应用程序,并使用 Electron 打包程序对其进行了打包。我制作了238MB的Windows bundle 包,而Linux版本是450 MB。我将其与也是 El
这个问题在这里已经有了答案: Generate an integer that is not among four billion given ones (38 个答案) 关闭 9 年前。 Give
我的 Meteor 应用程序获取一个 CSV 文件,使用 Baby Parse(Papa Parse for server)对其进行解析,并将数据插入到 MongoDB 集合中。 每个 CSV 行都作
Amazon SES 有 10 MB 的文件限制 我的问题是 有没有其他方法可以发送超过 10 MB 的文件? 最佳答案 这是一个硬限制。 您需要做的是包含您当前包含在电子邮件中的 Assets 的
我是一名优秀的程序员,十分优秀!