workflow.idgen.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. Licensed to Cloudera, Inc. under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. Cloudera, Inc. licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. "License"); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. */
  16. /**
  17. * ID Generator
  18. * Generate a new ID starting from 1.
  19. * - Accepts a prefix that will be prepended like so: <prefix>:<id number>
  20. */
  21. var IdGeneratorModule = function($) {
  22. return function(options) {
  23. var self = this;
  24. $.extend(self, options);
  25. self.counter = 1;
  26. self.nextId = function() {
  27. return ((self.prefix) ? self.prefix + ':' : '') + self.counter++;
  28. };
  29. };
  30. };
  31. var IdGenerator = IdGeneratorModule($);
  32. var IdGeneratorTable = {
  33. mapreduce: new IdGenerator({prefix: 'mapreduce'}),
  34. streaming: new IdGenerator({prefix: 'streaming'}),
  35. java: new IdGenerator({prefix: 'java'}),
  36. pig: new IdGenerator({prefix: 'pig'}),
  37. hive: new IdGenerator({prefix: 'hive'}),
  38. sqoop: new IdGenerator({prefix: 'sqoop'}),
  39. shell: new IdGenerator({prefix: 'shell'}),
  40. ssh: new IdGenerator({prefix: 'ssh'}),
  41. distcp: new IdGenerator({prefix: 'distcp'}),
  42. fs: new IdGenerator({prefix: 'fs'}),
  43. email: new IdGenerator({prefix: 'email'}),
  44. subworkflow: new IdGenerator({prefix: 'subworkflow'}),
  45. generic: new IdGenerator({prefix: 'generic'}),
  46. fork: new IdGenerator({prefix: 'fork'}),
  47. decision: new IdGenerator({prefix: 'decision'}),
  48. join: new IdGenerator({prefix: 'join'}),
  49. decisionend: new IdGenerator({prefix: 'decisionend'}),
  50. kill: new IdGenerator({prefix: 'kill'})
  51. };