Example usage for org.apache.hadoop.conf Configuration getInt

List of usage examples for org.apache.hadoop.conf Configuration getInt

Introduction

In this page you can find the example usage for org.apache.hadoop.conf Configuration getInt.

Prototype

public int getInt(String name, int defaultValue) 

Source Link

Document

Get the value of the name property as an int.

Usage

From source file:backup.namenode.NameNodeBackupServicePlugin.java

License:Apache License

@Override
public void start(Object service) {
    UserGroupInformation ugi;/*from   w  w w  . ja  v  a2 s.c  o  m*/
    try {
        ugi = UserGroupInformation.getCurrentUser();
        LOG.info("Starting NameNodeBackupServicePlugin with ugi {}", ugi);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    Configuration conf = getConf();
    NameNode namenode = (NameNode) service;
    BlockManager blockManager = namenode.getNamesystem().getBlockManager();
    // This object is created here so that it's lifecycle follows the namenode
    try {
        restoreProcessor = SingletonManager.getManager(NameNodeRestoreProcessor.class).getInstance(namenode,
                () -> new NameNodeRestoreProcessor(getConf(), namenode, ugi));
        LOG.info("NameNode Backup plugin setup using UGI {}", ugi);

        NameNodeBackupRPCImpl backupRPCImpl = new NameNodeBackupRPCImpl(blockManager);

        InetSocketAddress listenerAddress = namenode.getServiceRpcAddress();
        int ipcPort = listenerAddress.getPort();
        String bindAddress = listenerAddress.getAddress().getHostAddress();
        int port = conf.getInt(DFS_BACKUP_NAMENODE_RPC_PORT_KEY, DFS_BACKUP_NAMENODE_RPC_PORT_DEFAULT);
        if (port == 0) {
            port = ipcPort + 1;
        }
        server = new RPC.Builder(conf).setBindAddress(bindAddress).setPort(port).setInstance(backupRPCImpl)
                .setProtocol(NameNodeBackupRPC.class).build();
        ServiceAuthorizationManager serviceAuthorizationManager = server.getServiceAuthorizationManager();
        serviceAuthorizationManager.refresh(conf, new BackupPolicyProvider());
        server.start();

        LOG.info("NameNode Backup RPC listening on {}", port);

        int httpPort = getConf().getInt(DFS_BACKUP_NAMENODE_HTTP_PORT_KEY,
                DFS_BACKUP_NAMENODE_HTTP_PORT_DEFAULT);
        if (httpPort != 0) {
            ClassLoader classLoader = getClassLoader();
            if (classLoader != null) {
                ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
                try {
                    BackupWebService<Stats> stats = getBackupWebService(ugi, blockManager, restoreProcessor);

                    // Have to setup classloader in thread context to get the static
                    // files in the http server tp be setup correctly.
                    Thread.currentThread().setContextClassLoader(classLoader);
                    Class<?> backupStatusServerClass = classLoader.loadClass(BACKUP_WEB_BACKUP_WEB_SERVER);

                    Object server = DuckTypeUtil.newInstance(backupStatusServerClass,
                            new Class[] { Integer.TYPE, BackupWebService.class },
                            new Object[] { httpPort, stats });
                    httpServer = DuckTypeUtil.wrap(HttpServer.class, server);
                    httpServer.start();
                    LOG.info("NameNode Backup HTTP listening on {}", httpPort);
                } finally {
                    Thread.currentThread().setContextClassLoader(contextClassLoader);
                }
            } else {
                LOG.info("NameNode Backup HTTP classes not found.");
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:be.uantwerpen.adrem.bigfim.AprioriPhaseReducer.java

License:Apache License

@Override
public void setup(Context context) {
    Configuration conf = context.getConfiguration();

    minSup = conf.getInt(MIN_SUP_KEY, 1);

    getBaseDirs(context);/*from   w  w w. j a  va 2s .c  om*/
    tgIndex = getLargestIndex(conf, new Path(createPath(baseDir, "tg" + aprioriPhase)), "trieGroup", 1) + 1;
    fisIndex = getLargestIndex(conf, new Path(createPath(baseDir, OShortFIs)), "fis-" + aprioriPhase, 2) + 1;
    baseOutputPathFis = createPath(baseDir, OShortFIs, "fis-" + aprioriPhase + "-" + fisIndex);

    mos = new MultipleOutputs<Text, Writable>(context);
}

From source file:be.uantwerpen.adrem.bigfim.ComputeTidListReducer.java

License:Apache License

@Override
public void setup(Context context) {
    Configuration conf = context.getConfiguration();

    minSup = conf.getInt(MIN_SUP_KEY, 1);
    numberOfMappers = conf.getInt(NUMBER_OF_MAPPERS_KEY, 1);
    bucketSizes = newArrayListWithCapacity(numberOfMappers);
    for (int i = 0; i < numberOfMappers; i++) {
        bucketSizes.add(new MutableInt());
    }/*from w ww  .  j ava  2  s  .  c o  m*/

    getBasePGDir(context);
    getPgStartIndex(conf);

    mos = new MultipleOutputs<IntArrayWritable, IntMatrixWritable>(context);
}

From source file:be.uantwerpen.adrem.disteclat.ItemReaderReducer.java

License:Apache License

@Override
public void setup(Context context) {
    Configuration conf = context.getConfiguration();

    mos = new MultipleOutputs<IntWritable, Writable>(context);
    numberOfMappers = parseInt(conf.get(NUMBER_OF_MAPPERS_KEY, "1"));
    minSup = conf.getInt(MIN_SUP_KEY, -1);

    shortFisFilename = createPath(getJobAbsoluteOutputDir(context), OShortFIs, OShortFIs + "-1");
}

From source file:be.uantwerpen.adrem.disteclat.PrefixComputerMapper.java

License:Apache License

@Override
public void setup(Context context) throws IOException {
    try {/* ww  w .  ja  v  a 2  s .c  o  m*/
        Configuration conf = context.getConfiguration();

        minSup = conf.getInt(MIN_SUP_KEY, -1);
        prefixLength = conf.getInt(PREFIX_LENGTH_KEY, 1);

        Path[] localCacheFiles = getLocalCacheFiles(conf);

        for (Path path : localCacheFiles) {
            String pathString = path.toString();
            if (pathString.contains(OSingletonsTids)) {
                System.out.println("[PrefixComputerMapper]: Reading singletons");
                singletons = readTidLists(conf, path);
            } else if (pathString.contains(OSingletonsOrder)) {
                System.out.println("[PrefixComputerMapper]: Reading singleton orders");
                orderMap = readSingletonsOrder(path);
            }
        }

        sortSingletons();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:be.uantwerpen.adrem.disteclat.PrefixComputerReducer.java

License:Apache License

@Override
public void setup(Context context) throws IOException {
    Configuration conf = context.getConfiguration();

    createShortFIsFile(context);/*from  w ww . j  av  a 2 s .c o m*/

    minSup = conf.getInt(MIN_SUP_KEY, 1);
    int numberOfMappers = conf.getInt(NUMBER_OF_MAPPERS_KEY, 1);
    bucketSizes = newArrayListWithCapacity(numberOfMappers);
    for (int i = 0; i < numberOfMappers; i++) {
        bucketSizes.add(new MutableInt());
    }

    mos = new MultipleOutputs<IntArrayWritable, IntMatrixWritable>(context);
}

From source file:be.uantwerpen.adrem.eclat.EclatMinerMapperBase.java

License:Apache License

@Override
public void setup(Context context) throws IOException {
    Configuration conf = context.getConfiguration();

    minSup = conf.getInt(MIN_SUP_KEY, 1);

    extensions = newArrayList();// w  w  w. j  a  v  a2s .co m
}

From source file:be.ugent.intec.halvade.utils.HalvadeConf.java

License:Open Source License

public static int getVcores(Configuration conf) {
    return conf.getInt(vCores, 1);
}

From source file:be.ugent.intec.halvade.utils.HalvadeConf.java

License:Open Source License

public static int getMapThreads(Configuration conf) {
    return conf.getInt(mapThreads, 1);
}

From source file:be.ugent.intec.halvade.utils.HalvadeConf.java

License:Open Source License

public static int getReducerThreads(Configuration conf) {
    return conf.getInt(reduceThreads, 1);
}