private FileSplit getDefaultOutputFileLocation(ICcApplicationContext appCtx) throws AlgebricksException { String outputDir = System.getProperty("java.io.tmpDir"); String filePath = outputDir + System.getProperty("file.separator") + OUTPUT_FILE_PREFIX + outputFileID.incrementAndGet(); MetadataProperties metadataProperties = appCtx.getMetadataProperties(); return new ManagedFileSplit(metadataProperties.getMetadataNodeName(), filePath); }
private MetadataProperties mockMetadataProperties() { SortedMap<Integer, ClusterPartition> clusterPartitions = Collections.synchronizedSortedMap(new TreeMap<>()); Map<String, ClusterPartition[]> nodePartitionsMap = new ConcurrentHashMap<>(); nodePartitionsMap.put(METADATA_NODE, new ClusterPartition[] { new ClusterPartition(0, METADATA_NODE, 0) }); MetadataProperties metadataProperties = Mockito.mock(MetadataProperties.class); Mockito.when(metadataProperties.getMetadataNodeName()).thenReturn(METADATA_NODE); Mockito.when(metadataProperties.getClusterPartitions()).thenReturn(clusterPartitions); Mockito.when(metadataProperties.getNodePartitions()).thenReturn(nodePartitionsMap); return metadataProperties; }
@Override public synchronized void init() throws HyracksDataException { if (metadataNode != null && !rebindMetadataNode) { return; } try { metadataNode = proxies.iterator().next() .waitForMetadataNode(metadataProperties.getRegistrationTimeoutSecs(), TimeUnit.SECONDS); if (metadataNode != null) { rebindMetadataNode = false; } else { throw new HyracksDataException("The MetadataNode failed to bind before the configured timeout (" + metadataProperties.getRegistrationTimeoutSecs() + " seconds); the MetadataNode was " + "configured to run on NC: " + metadataProperties.getMetadataNodeName()); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw HyracksDataException.create(e); } catch (RemoteException e) { throw new RuntimeDataException(ErrorCode.REMOTE_EXCEPTION_WHEN_CALLING_METADATA_NODE, e); } super.init(); } }
@Override public void setCcAppCtx(ICcApplicationContext appCtx) { this.appCtx = appCtx; node2PartitionsMap = appCtx.getMetadataProperties().getNodePartitions(); clusterPartitions = appCtx.getMetadataProperties().getClusterPartitions(); currentMetadataNode = appCtx.getMetadataProperties().getMetadataNodeName(); metadataPartition = node2PartitionsMap.get(currentMetadataNode)[0]; lifecycleCoordinator = appCtx.getNcLifecycleCoordinator(); lifecycleCoordinator.bindTo(this); }
metadataNodeName = metadataProperties.getMetadataNodeName(); nodeNames = metadataProperties.getNodeNames(); localResourceRepository = appContext.getLocalResourceRepository();