Puppet Class: hadoop::zkfc::service

Defined in:
manifests/zkfc/service.pp

Overview

Class hadoop::zkfc:service:

This class is meant to be called from hadoop::zkfc. It ensures the service is running.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'manifests/zkfc/service.pp', line 6

class hadoop::zkfc::service {
  # zkfc requires working zookeeper first
  if $hadoop::zookeeper_deployed {
    service { $hadoop::daemons['hdfs-zkfc']:
      ensure    => 'running',
      enable    => true,
      subscribe => [File["${hadoop::confdir}/core-site.xml"], File["${hadoop::confdir}/hdfs-site.xml"]],
    }

    # launch the format only once: on the first (main) namenode
    if $hadoop::hdfs_enable and $hadoop::zookeeper_hostnames and $hadoop::hdfs_hostname == $::fqdn {
      hadoop::kinit {'hdfs-zkfc-kinit':
        touchfile => 'hdfs-zkfc-formatted',
      }
      ->
      exec {'hdfs-zkfc-format':
        # If the znode created by -formatZK already exists, and for
        # some buggy reason it happens to run, -formatZK will prompt
        # the user to confirm if the znode should be reformatted.
        # Puppet isn't able to answer this question on its own.
        # Default to answering with 'N' if the command asks.
        # This should never happen, but just in case it does,
        # We don't want this eternally unanswered prompt to fill up
        # puppet logs and disks.
        command => 'echo N | hdfs zkfc -formatZK',
        path    => '/sbin:/usr/sbin:/bin:/usr/bin',
        user    => 'hdfs',
        creates => '/var/lib/hadoop-hdfs/.puppet-hdfs-zkfc-formatted',
        # acceptable responses 0 = success, 2 = znode already exists
        returns => [ '0', '2', ],
      }
      ->
      hadoop::kdestroy {'hdfs-zkfc-kdestroy':
        touchfile => 'hdfs-zkfc-formatted',
        touch     => true,
      }
      ->
      Service[$hadoop::daemons['hdfs-zkfc']]

      Service[$hadoop::daemons['hdfs-zkfc']] -> Hadoop::Mkdir <| |>
    }
  }
}