List of usage examples for java.util ArrayList iterator
public Iterator<E> iterator()
From source file:org.archive.crawler.frontier.WorkQueueFrontier.java
/** * This method compiles a human readable report on the status of the frontier * at the time of the call./*from w w w . j a v a 2s . com*/ * @param name Name of report. * @param writer Where to write to. */ @Override public synchronized void reportTo(PrintWriter writer) { int allCount = allQueues.size(); int inProcessCount = inProcessQueues.size(); int readyCount = readyClassQueues.size(); int snoozedCount = getSnoozedCount(); int activeCount = inProcessCount + readyCount + snoozedCount; int inactiveCount = getTotalInactiveQueues(); int retiredCount = getRetiredQueues().size(); int exhaustedCount = allCount - activeCount - inactiveCount - retiredCount; writer.print("Frontier report - "); writer.print(ArchiveUtils.get12DigitDate()); writer.print("\n"); writer.print(" Job being crawled: "); writer.print(controller.getMetadata().getJobName()); writer.print("\n"); writer.print("\n -----===== STATS =====-----\n"); writer.print(" Discovered: "); writer.print(Long.toString(discoveredUriCount())); writer.print("\n"); writer.print(" Queued: "); writer.print(Long.toString(queuedUriCount())); writer.print("\n"); writer.print(" Finished: "); writer.print(Long.toString(finishedUriCount())); writer.print("\n"); writer.print(" Successfully: "); writer.print(Long.toString(succeededFetchCount())); writer.print("\n"); writer.print(" Failed: "); writer.print(Long.toString(failedFetchCount())); writer.print("\n"); writer.print(" Disregarded: "); writer.print(Long.toString(disregardedUriCount())); writer.print("\n"); writer.print("\n -----===== QUEUES =====-----\n"); writer.print(" Already included size: "); writer.print(Long.toString(uriUniqFilter.count())); writer.print("\n"); writer.print(" pending: "); writer.print(Long.toString(uriUniqFilter.pending())); writer.print("\n"); writer.print("\n All class queues map size: "); writer.print(Long.toString(allCount)); writer.print("\n"); writer.print(" Active queues: "); writer.print(activeCount); writer.print("\n"); writer.print(" In-process: "); writer.print(inProcessCount); writer.print("\n"); writer.print(" Ready: "); writer.print(readyCount); writer.print("\n"); writer.print(" Snoozed: "); writer.print(snoozedCount); writer.print("\n"); writer.print(" Inactive queues: "); writer.print(inactiveCount); writer.print(" ("); Map<Integer, Queue<String>> inactives = getInactiveQueuesByPrecedence(); boolean betwixt = false; for (Integer k : inactives.keySet()) { if (betwixt) { writer.print("; "); } writer.print("p"); writer.print(k); writer.print(": "); writer.print(inactives.get(k).size()); betwixt = true; } writer.print(")\n"); writer.print(" Retired queues: "); writer.print(retiredCount); writer.print("\n"); writer.print(" Exhausted queues: "); writer.print(exhaustedCount); writer.print("\n"); State last = lastReachedState; writer.print("\n Last state: " + last); writer.print("\n -----===== MANAGER THREAD =====-----\n"); ToeThread.reportThread(managerThread, writer); writer.print("\n -----===== " + largestQueues.size() + " LONGEST QUEUES =====-----\n"); appendQueueReports(writer, "LONGEST", largestQueues.getEntriesDescending().iterator(), largestQueues.size(), largestQueues.size()); writer.print("\n -----===== IN-PROCESS QUEUES =====-----\n"); Collection<WorkQueue> inProcess = inProcessQueues; ArrayList<WorkQueue> copy = extractSome(inProcess, maxQueuesPerReportCategory); appendQueueReports(writer, "IN-PROCESS", copy.iterator(), copy.size(), maxQueuesPerReportCategory); writer.print("\n -----===== READY QUEUES =====-----\n"); appendQueueReports(writer, "READY", this.readyClassQueues.iterator(), this.readyClassQueues.size(), maxQueuesPerReportCategory); writer.print("\n -----===== SNOOZED QUEUES =====-----\n"); Object[] objs = snoozedClassQueues.toArray(); DelayedWorkQueue[] qs = Arrays.copyOf(objs, objs.length, DelayedWorkQueue[].class); Arrays.sort(qs); appendQueueReports(writer, "SNOOZED", new ObjectArrayIterator(qs), getSnoozedCount(), maxQueuesPerReportCategory); writer.print("\n -----===== INACTIVE QUEUES =====-----\n"); SortedMap<Integer, Queue<String>> sortedInactives = getInactiveQueuesByPrecedence(); for (Integer prec : sortedInactives.keySet()) { Queue<String> inactiveQueues = sortedInactives.get(prec); appendQueueReports(writer, "INACTIVE-p" + prec, inactiveQueues.iterator(), inactiveQueues.size(), maxQueuesPerReportCategory); } writer.print("\n -----===== RETIRED QUEUES =====-----\n"); appendQueueReports(writer, "RETIRED", getRetiredQueues().iterator(), getRetiredQueues().size(), maxQueuesPerReportCategory); writer.flush(); }
From source file:fr.inria.oak.paxquery.pact.operations.xml.navigation.SingleDocumentExtractor.java
/** * Fetches all stacks of a given tag/*from w w w . j av a 2 s. c o m*/ */ private final Iterator<ExtractorMatchStack> stacksCompatibleWithTag(String s) { ArrayList<ExtractorMatchStack> v = stacksByTag.get(s); ArrayList<ExtractorMatchStack> stars = stacksByTag.get("{}*"); if (stars == null) { if (v == null) { return (new ArrayList<ExtractorMatchStack>()).iterator(); } return v.iterator(); } if (v == null) { return stars.iterator(); } // v != null and stars != null ArrayList<ExtractorMatchStack> vRes = new ArrayList<ExtractorMatchStack>(); Iterator<ExtractorMatchStack> it = v.iterator(); while (it.hasNext()) { vRes.add(it.next()); } it = stars.iterator(); while (it.hasNext()) { vRes.add(it.next()); } return vRes.iterator(); }
From source file:com.tacitknowledge.util.migration.DistributedMigrationProcess.java
/** * Applies necessary patches to the system. * * @param patchInfoStore of the system to run * @param context information and resources that are available to the migration tasks * @return the number of <code>MigrationTask</code>s that have executed * @throws MigrationException if a migration fails * @Override/*from w w w .java2s. c om*/ */ public final int doMigrations(final PatchInfoStore patchInfoStore, final MigrationContext context) throws MigrationException { log.debug("Starting doMigrations"); // Get all the migrations, with their launchers, then get the list of // just the migrations LinkedHashMap migrationsWithLaunchers = getMigrationTasksWithLaunchers(); List migrations = new ArrayList(); migrations.addAll(migrationsWithLaunchers.keySet()); // make sure the migrations are okay, then sort them validateTasks(migrations); Collections.sort(migrations); validateControlledSystems(patchInfoStore); // determine how many tasks we're going to execute int taskCount = patchDryRun(patchInfoStore, migrationsWithLaunchers); if (taskCount > 0) { log.info("A total of " + taskCount + " patch tasks will execute."); } else { log.info("System up-to-date. No patch tasks will execute."); } // See if we should execute if (isReadOnly()) { if (taskCount > 0) { throw new MigrationException("Unapplied patches exist, but read-only flag is set"); } log.info("In read-only mode - skipping patch application"); return 0; } // Roll through each migration, applying it if necessary taskCount = 0; for (Iterator i = migrations.iterator(); i.hasNext();) { MigrationTask task = (MigrationTask) i.next(); int migrationLevel = task.getLevel().intValue(); boolean shouldApplyPatch = getMigrationRunnerStrategy().shouldMigrationRun(migrationLevel, patchInfoStore); if (shouldApplyPatch && !forceSync) { // Execute the task in the context it was loaded from JdbcMigrationLauncher launcher = (JdbcMigrationLauncher) migrationsWithLaunchers.get(task); // Get all the contexts the task will execute in for (Iterator j = launcher.getContexts().keySet().iterator(); j.hasNext();) { MigrationContext launcherContext = (MigrationContext) j.next(); applyPatch(launcherContext, task, true); } taskCount++; } else if (forceSync)// if a sync is forced, need to check all // the contexts to identify the ones out of // sync { boolean patchesApplied = false; ArrayList outOfSyncContexts = new ArrayList(); // first need to iterate over all the contexts and determined // which one's are out of sync. // can't sync yet because if there are multiple contexts that // are out of sync, after the // first one is synced, the remaining one's have their patch // level updated via the // MigrationListener.migrationSuccessful event. JdbcMigrationLauncher launcher = (JdbcMigrationLauncher) migrationsWithLaunchers.get(task); for (Iterator j = launcher.getContexts().keySet().iterator(); j.hasNext();) { MigrationContext launcherContext = (MigrationContext) j.next(); PatchInfoStore patchInfoStoreOfContext = (PatchInfoStore) launcher.getContexts() .get(launcherContext); if (!getMigrationRunnerStrategy().isSynchronized(patchInfoStore, patchInfoStoreOfContext)) { outOfSyncContexts.add(launcherContext); } } // next patch the contexts that have been determined to be out // of sync for (Iterator iter = outOfSyncContexts.iterator(); iter.hasNext();) { MigrationContext launcherContext = (MigrationContext) iter.next(); applyPatch(launcherContext, task, true); patchesApplied = true; } if (patchesApplied) { taskCount++; } } // else if forceSync } if (taskCount > 0) { log.info("Patching complete (" + taskCount + " patch tasks executed)"); } else { log.info("System up-to-date. No patch tasks have been run."); } return taskCount; }
From source file:com.planetmayo.debrief.satc_rcp.views.MaintainContributionsView.java
protected void redoStraightLegs() { // ok, clear any leg markers if (legPlot != null) { if (!graphTabs.isDisposed()) graphTabs.setSelection(legTab); // hmm, actually we have to remove any target leg markers @SuppressWarnings("unchecked") Collection<IntervalMarker> markers = legPlot.getDomainMarkers(Layer.FOREGROUND); if (markers != null) { ArrayList<IntervalMarker> markersToDelete = new ArrayList<IntervalMarker>(markers); Iterator<IntervalMarker> mIter = markersToDelete.iterator(); while (mIter.hasNext()) { IntervalMarker im = mIter.next(); legPlot.removeDomainMarker(im); }//from ww w.j av a 2 s . co m } Iterator<BaseContribution> conts = activeSolver.getContributions().iterator(); while (conts.hasNext()) { BaseContribution baseC = conts.next(); if (baseC.isActive()) if (baseC instanceof StraightLegForecastContribution) { StraightLegForecastContribution slf = (StraightLegForecastContribution) baseC; java.awt.Color thisCol = slf.getColor(); // hmm, has it been given a color (initialised) yet? if (thisCol == null) continue; long thisStart = baseC.getStartDate().getTime(); long thisFinish = baseC.getFinishDate().getTime(); java.awt.Color transCol = new java.awt.Color(255, 0, 0, 22); final Marker bst = new IntervalMarker(thisStart, thisFinish, transCol, new BasicStroke(2.0f), null, null, 1.0f); bst.setLabel(baseC.getName()); bst.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); bst.setLabelFont(new Font("SansSerif", Font.ITALIC + Font.BOLD, 10)); bst.setLabelTextAnchor(TextAnchor.BASELINE_LEFT); legPlot.addDomainMarker(bst, Layer.FOREGROUND); } else { if (baseC instanceof BearingMeasurementContribution) { } } } } }
From source file:fr.inria.oak.paxquery.pact.operations.xml.navigation.SingleDocumentExtractor.java
/** * Checks if the match produced by the current node, on the stack s, has * all required child matches (that is, at least a required child match for * each required child)./* ww w .j a va 2s. co m*/ * * It also fills in the match with the children that it had by transitivity * only * * @param s * @param endingNode */ private final void checkPruneAndFillIn(ExtractorMatchStack s, int endingNode) { ExtractorMatch se = s.findEntry(endingNode); if (se != null) { NavigationTreePatternNode pns = this.nodesByStacks.get(s); // this means all required children have been matched boolean childrenPresent = true; boolean correctValue = true; // checking value condition first if (pns.selectsValue()) { if (pns.getStringValue() != null) { String thisVal = pns.getStringValue(); if (se.getVal() == null) { correctValue = false; } else { if (thisVal.startsWith("~")) { Pattern p = Pattern.compile("(^|\\s+|[^a-zA-Z0-9]+)" + thisVal.substring(1, thisVal.length()) + "($|\\s+|[^a-zA-Z0-9]+)", Pattern.MULTILINE); Matcher m = p.matcher(se.getVal()); if (!m.find()) correctValue = false; } else { String otherVal = se.getVal(); switch (pns.getSelectOnValuePredicate()) { case PREDICATE_EQUAL: correctValue = otherVal.compareTo(thisVal) == 0; break; case PREDICATE_GREATEROREQUALTHAN: correctValue = otherVal.compareTo(thisVal) >= 0; break; case PREDICATE_GREATERTHAN: correctValue = otherVal.compareTo(thisVal) > 0; break; case PREDICATE_NOTEQUAL: correctValue = otherVal.compareTo(thisVal) != 0; break; case PREDICATE_SMALLEROREQUALTHAN: correctValue = otherVal.compareTo(thisVal) <= 0; break; case PREDICATE_SMALLERTHAN: correctValue = otherVal.compareTo(thisVal) < 0; break; default: logger.error("Predicate not supported in tree pattern!"); } } } } else { double thisVal = pns.getDoubleValue(); if (se.getVal() == null) { correctValue = false; } else { double otherVal = Double.parseDouble(se.getVal()); switch (pns.getSelectOnValuePredicate()) { case PREDICATE_EQUAL: correctValue = otherVal == thisVal; break; case PREDICATE_GREATEROREQUALTHAN: correctValue = otherVal >= thisVal; break; case PREDICATE_GREATERTHAN: correctValue = otherVal > thisVal; break; case PREDICATE_NOTEQUAL: correctValue = otherVal != thisVal; break; case PREDICATE_SMALLEROREQUALTHAN: correctValue = otherVal <= thisVal; break; case PREDICATE_SMALLERTHAN: correctValue = otherVal < thisVal; break; default: logger.error("Predicate not supported in tree pattern!"); } } } } if (correctValue) { Iterator<NavigationTreePatternEdge> iChildren = pns.getEdges().iterator(); while (iChildren.hasNext()) { NavigationTreePatternEdge thisEdge = iChildren.next(); // Only if it is not optional if (!thisEdge.isOptional()) { NavigationTreePatternNode nChild = thisEdge.n2; // stack for this child ExtractorMatchStack sChild = stacksByNodes.get(nChild); boolean hasChildInThisStack = (findChildInStack(se, sChild, thisEdge.isParent()) != null); if (!hasChildInThisStack) { childrenPresent = false; } else { boolean thisChildPresent = false; ArrayList<ExtractorMatch> o = se.childrenByStack.get(sChild); Iterator<ExtractorMatch> itChildrenThisStack = o.iterator(); while (itChildrenThisStack.hasNext()) { ExtractorMatch emChild = itChildrenThisStack.next(); if (emChild.erased) { } else { thisChildPresent = true; } } if (!thisChildPresent) { childrenPresent = false; } } } } } // connecting to the last open match in this stack, if necessary if (s.dnop == se) { s.dnop = se.ownParent; } // dropping this match if some required child is absent if ((!childrenPresent) || (!correctValue)) { se.erased = true; // dropping also what is underneath s.removeEntry(se); // clearing context if (s.dnop == null) { this.currentContexts.remove(pns); } // if se has no ownParent, then we can erase all its // descendant matches. if (se.ownParent == null) { // erase se's children Iterator<ArrayList<ExtractorMatch>> itChildren = se.childrenByStack.values().iterator(); while (itChildren.hasNext()) { Iterator<ExtractorMatch> it4 = itChildren.next().iterator(); while (it4.hasNext()) { ExtractorMatch sChild = it4.next(); sChild.recErase(); } } } else { // se.ownParent is not null // go see the children and connect them to the ownParent // tell the parent that these are its children int cnt = 0; Iterator<ArrayList<ExtractorMatch>> itChildren = se.childrenByStack.values().iterator(); while (itChildren.hasNext()) { cnt += itChildren.next().size(); } if (cnt > 0) { itChildren = se.childrenByStack.values().iterator(); while (itChildren.hasNext()) { Iterator<ExtractorMatch> it4 = itChildren.next().iterator(); while (it4.hasNext()) { ExtractorMatch sChild = it4.next(); ExtractorMatchStack theChildsStack = sChild.theStack; NavigationTreePatternNode sesNode = this.nodesByStacks.get(se.theStack); NavigationTreePatternNode sChildsNode = this.nodesByStacks.get(theChildsStack); // learn if this matches for the child node were supposed to be direct // descendants of their parent: boolean wasParentEdge = false; if (sesNode.getEdges() != null) { Iterator<NavigationTreePatternEdge> itEdges = sesNode.getEdges().iterator(); while (itEdges.hasNext()) { NavigationTreePatternEdge pe = itEdges.next(); if (pe.n2 == sChildsNode) { if (pe.isParent()) { wasParentEdge = true; } } } // now establish if it is OK to reconnect the children to their // parent's own parent if (!wasParentEdge || (se.ownParent.depth + 1 == sChild.depth)) { sChild.ownParent = se.ownParent; se.ownParent.addChild(sChild, sChild.theStack); } } } } } } } } }
From source file:com.projity.pm.dependency.DependencyService.java
/** * Connect tasks sequentially.//w w w .j ava 2s .c om * Circularities will be tested, and an exception thrown if any circularity would occur * * @param tasks * @param eventSource * @throws InvalidAssociationException */ public void connect(List tasks, Object eventSource, Predicate canBeSuccessorCondition) throws InvalidAssociationException { ArrayList newDependencies = new ArrayList(); // try making new dependencies between all items earlier to all items later, thereby checking all possible circularities HasDependencies pred; HasDependencies succ; Object temp; for (int i = 0; i < tasks.size() - 1; i++) { temp = tasks.get(i); if (!(temp instanceof HasDependencies)) continue; pred = (HasDependencies) temp; for (int j = i + 1; j < tasks.size(); j++) { temp = tasks.get(j); if (!(temp instanceof HasDependencies)) continue; succ = (HasDependencies) temp; if (canBeSuccessorCondition != null && !canBeSuccessorCondition.evaluate(succ)) // allow exclusion of certain nodes that we don't want to be successors continue; if (succ.getPredecessorList().findLeft(pred) != null) // if dependency already exists, skip it continue; if (ClassUtils.isObjectReadOnly(succ)) continue; Dependency test = Dependency.getInstance(pred, succ, DependencyType.FS, 0); // make a new one test.testValid(false); // test for circularity, throws if bad if (j == i + 1) // only add sequential ones newDependencies.add(test); } } Iterator d = newDependencies.iterator(); while (d.hasNext()) { connect((Dependency) d.next(), eventSource); } }
From source file:com.cyberway.issue.crawler.frontier.WorkQueueFrontier.java
/** Compact report of all nonempty queues (one queue per line) * /*from w ww. j ava2s . c om*/ * @param writer */ private void allNonemptyReportTo(PrintWriter writer) { ArrayList<WorkQueue> inProcessQueuesCopy; synchronized (this.inProcessQueues) { // grab a copy that will be stable against mods for report duration @SuppressWarnings("unchecked") Collection<WorkQueue> inProcess = this.inProcessQueues; inProcessQueuesCopy = new ArrayList<WorkQueue>(inProcess); } writer.print("\n -----===== IN-PROCESS QUEUES =====-----\n"); queueSingleLinesTo(writer, inProcessQueuesCopy.iterator()); writer.print("\n -----===== READY QUEUES =====-----\n"); queueSingleLinesTo(writer, this.readyClassQueues.iterator()); writer.print("\n -----===== SNOOZED QUEUES =====-----\n"); queueSingleLinesTo(writer, this.snoozedClassQueues.iterator()); writer.print("\n -----===== INACTIVE QUEUES =====-----\n"); queueSingleLinesTo(writer, this.inactiveQueues.iterator()); writer.print("\n -----===== RETIRED QUEUES =====-----\n"); queueSingleLinesTo(writer, this.retiredQueues.iterator()); }
From source file:com.dtolabs.client.services.RundeckAPICentralDispatcher.java
/** * Submit a request to the server which expects a list of execution items in the response, and return a single * QueuedItemResult parsed from the response. * * @param tempxml xml temp file (or null) * @param otherparams parameters for the request * @param requestPath/* ww w . j a v a2 s .co m*/ * * @return a single QueuedItemResult * * @throws com.dtolabs.rundeck.core.dispatcher.CentralDispatcherException * if an error occurs */ private QueuedItemResult submitExecutionRequest(final File tempxml, final HashMap<String, String> otherparams, final String requestPath) throws CentralDispatcherException { final HashMap<String, String> params = new HashMap<String, String>(); if (null != otherparams) { params.putAll(otherparams); } final WebserviceResponse response; try { response = serverService.makeRundeckRequest(requestPath, params, tempxml, null, "xmlBatch"); } catch (MalformedURLException e) { throw new CentralDispatcherServerRequestException("Failed to make request", e); } validateResponse(response); final ArrayList<QueuedItem> list = parseExecutionListResult(response); if (null == list || list.size() < 1) { return QueuedItemResultImpl.failed("Server response contained no success information."); } else { final QueuedItem next = list.iterator().next(); return QueuedItemResultImpl.successful("Succeeded queueing " + next.getName(), next.getId(), next.getUrl(), next.getName()); } }
From source file:com.projity.pm.task.ProjectFactory.java
/** * @param project/* w w w . j av a 2 s . c o m*/ * @param allowCancel * @param prompt * @return null if cancelled */ public Job getRemoveProjectJob(final Project project, boolean allowCancel, boolean prompt, boolean calledFromSwing) { Job job = null; if (prompt && project.needsSaving()) { // final boolean[] lock=new boolean[]{false}; // SwingUtilities.invokeLater(new Runnable(){ // public void run(){ // Alert.okCancel("test"); // synchronized (lock) { // lock[0]=true; // lock.notifyAll(); // } // } // }); // synchronized(lock){ // while (!lock[0]){ // try{ // lock.wait(); // }catch (InterruptedException e) {} // } // } int promptResult = promptForSave(project, allowCancel); if (promptResult == JOptionPane.YES_OPTION) { SaveOptions opt = new SaveOptions(); opt.setLocal(project.isLocal()); if (project.isLocal()) { String fileName = project.getFileName(); if (fileName == null) { fileName = SessionFactory.getInstance().getLocalSession().chooseFileName(true, project.getGuessedFileName()); } if (fileName == null) return null; project.setFileName(fileName); opt.setFileName(fileName); opt.setImporter(LocalSession.getImporter(project.getFileType())); } job = getSaveProjectJob(project, opt); } else if (promptResult == JOptionPane.CANCEL_OPTION) return null; } final ArrayList toRemove = new ArrayList(); final ArrayList projects = new ArrayList(); DeepChildWalker.recursivelyTreatBranch(portfolio.getNodeModel(), project, new Closure() { public void execute(Object arg0) { Node node = (Node) arg0; Object impl = node.getImpl(); if (!(impl instanceof Project)) return; final Project p = (Project) impl; toRemove.add(node); if (Environment.getStandAlone() || project.isLockable()) { projects.add(p); } } }); Job closeProjectJob = getCloseProjectsOnServerJob(projects); if (closeProjectJob == null) { closeProjectJob = new Job(SessionFactory.getInstance().getJobQueue(), "closeProjects", "Closing...", false); } if (job == null) job = closeProjectJob; else job.addJob(closeProjectJob); job.addRunnable(new JobRunnable("Local: closeProjects") { public Object run() throws Exception { Iterator i = toRemove.iterator(); while (i.hasNext()) { Node node = (Node) i.next(); Project p = (Project) node.getImpl(); portfolio.handleExternalTasks(p, false, false); // external link handling p.getResourcePool().removeProject(p); p.disconnect(); portfolio.getObjectEventManager().fireDeleteEvent(this, p); portfolio.getNodeModel().remove(node, NodeModel.EVENT); removeClosingProject(project.getUniqueId()); } System.gc(); // clean up memory used by projects return null; //return not used anyway } }, /*!calledFromSwing*/false, false, calledFromSwing, false); return job; }
From source file:com.hortonworks.atlas.client.HiveMetaDataGenerator.java
/** * This is a generic method for mysql tables * @param dbReference//from ww w .j a va2 s. c o m * @param dbName * @param tableName * @return * @throws Exception */ public Referenceable registerExtTable(Referenceable dbReference, String dbName, String tableName, ArrayList<Column> clist) throws Exception { LOG.info("Attempting to register table [" + tableName + "]"); Referenceable tableRef = getTableReference(dbName, tableName); if (tableRef == null) { LOG.info("Importing objects from " + dbName + "." + tableName); //Table hiveTable = hiveClient.getTable(dbName, tableName); tableRef = new Referenceable(HiveDataTypes.HIVE_TABLE.getName()); tableRef.set(HiveDataModelGenerator.NAME, getTableName(clusterName, dbName, tableName)); tableRef.set(HiveDataModelGenerator.TABLE_NAME, tableName.toLowerCase()); tableRef.set("owner", "Hortonworks"); tableRef.set("createTime", System.currentTimeMillis()); tableRef.set("lastAccessTime", System.currentTimeMillis()); tableRef.set("retention", System.currentTimeMillis()); tableRef.set(HiveDataModelGenerator.COMMENT, "This is loaded from mysql tables"); // add reference to the database tableRef.set(HiveDataModelGenerator.DB, dbReference); Builder bld = ImmutableList.<Referenceable>builder(); Iterator<Column> itrc = clist.iterator(); ImmutableList<Referenceable> lst = ImmutableList.of(); Referenceable colref; while (itrc.hasNext()) { Column c = itrc.next(); colref = this.rawColumn(c.getColumn_name(), c.getColumn_type(), c.getColumn_remarks()); bld.add(colref); } lst = bld.build(); tableRef.set("columns", lst); tableRef.set("viewOriginalText", "Original text"); tableRef.set("viewExpandedText", "Expanded Text"); tableRef.set("tableType", "Mysql Imported table"); tableRef.set("temporary", "false"); tableRef = createInstance(tableRef); } else { LOG.info("Table {}.{} is already registered with id {}", dbName, tableName, tableRef.getId().id); } return tableRef; }