1

I wrote a HiveQL script like:

create temporary function getdomainips as 'com.is.mail.domainspf.IpFromDomainExtract';
select Domain,getdomainips(Domain) as ips from tmp_domain;

And IpFromDomainExtract class is as followings:

package com.is.mail.domainspf;

import org.apache.hadoop.hive.ql.exec.UDF;

import java.util.ArrayList;
import java.util.Arrays;

public class IpFromDomainExtract extends UDF {
    public ArrayList<String> evaluate(String domain) {
        try {
            if (domain == null || "".equals(domain)) {
                return new ArrayList<String>();
            }
            return new ArrayList<String>(Arrays.asList(UrlDomainDigHelper.getARecord(domain).split(",")));
        } catch (Exception e) {
            return new ArrayList<String>();
        }
    }
}


import java.net.UnknownHostException;

import org.xbill.DNS.ARecord;
import org.xbill.DNS.ExtendedResolver;
import org.xbill.DNS.Lookup;
import org.xbill.DNS.Record;
import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;

/**
*use dnsjava jar package
*/
class UrlDomainDigHelper {
    private static ExtendedResolver resolver;

    public static String getARecord(String d) throws TextParseException, UnknownHostException {
        if (resolver == null) {
            synchronized (UrlDomainDigHelper.class) {
                if (resolver == null) {
                    ExtendedResolver tmpresolver = new ExtendedResolver();
                    tmpresolver.setTimeout(5);
                    resolver = tmpresolver;
                }
            }
        }
        Lookup lookup = new Lookup(d, Type.A);
        if (resolver != null)
            lookup.setResolver(resolver);
        Record[] records = lookup.run();
        StringBuilder sb = new StringBuilder();
        if (records != null) {
            for (int i = 0; i < records.length; i++) {
                ARecord mx = (ARecord) records[i];
                sb.append(mx.getAddress().getHostAddress()).append(",");
            }
        }
        if (sb.length() > 0)
            sb.setLength(sb.length() - 1);
        return sb.toString();
    }
}

When I ran the HiveQL script,I got stuck at map=12% just as followings:

2016-01-06 16:14:06,701 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 105.67 sec 2016-01-06 16:15:07,172 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 106.7 sec 2016-01-06 16:16:07,317 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 107.87 sec 2016-01-06 16:17:07,501 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 108.84 sec 2016-01-06 16:18:07,680 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 109.71 sec 2016-01-06 16:19:07,870 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 110.37 sec 2016-01-06 16:20:08,014 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 111.5 sec 2016-01-06 16:21:08,234 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 112.76 sec 2016-01-06 16:22:08,494 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 113.78 sec 2016-01-06 16:23:08,789 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 114.97 sec 2016-01-06 16:24:09,191 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 115.84 sec 2016-01-06 16:25:09,537 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 116.79 sec 2016-01-06 16:26:09,779 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 117.69 sec 2016-01-06 16:27:10,106 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 118.91 sec 2016-01-06 16:28:10,213 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 119.94 sec 2016-01-06 16:29:10,826 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 120.76 sec 2016-01-06 16:30:11,158 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 122.2 sec 2016-01-06 16:31:11,433 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 123.26 sec 2016-01-06 16:32:11,564 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 124.28 sec 2016-01-06 16:33:12,093 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 124.9 sec 2016-01-06 16:34:12,319 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 125.82 sec 2016-01-06 16:35:12,556 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 126.79 sec 2016-01-06 16:36:12,978 Stage-1 map = 12%, reduce = 0%, Cumulative CPU 127.57 sec

when I use jstack to view MapReduce Job Process Info,I got the following result:

"main" prio=10 tid=0x000000000122e000 nid=0x6908 in Object.wait() [0x00007fc884fa7000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000eab6b780> (a org.xbill.DNS.ExtendedResolver$Resolution) at java.lang.Object.wait(Object.java:502) at org.xbill.DNS.ExtendedResolver$Resolution.start(ExtendedResolver.java:111) - locked <0x00000000eab6b780> (a org.xbill.DNS.ExtendedResolver$Resolution) at org.xbill.DNS.ExtendedResolver.send(ExtendedResolver.java:358) at org.xbill.DNS.Lookup.lookup(Lookup.java:477) at org.xbill.DNS.Lookup.resolve(Lookup.java:529) at org.xbill.DNS.Lookup.run(Lookup.java:546)

I think I got a deadlock,how could I do to solve the problem in case of I already have used the latest dnsjava jar package(which is 2.1.7 version)? thanks very much.

user2351281
  • 137
  • 1
  • 8

0 Answers0