コード例 #1
0
        private void ParseAutofillFields(AssistStructure.ViewNode viewNode,
                                         Dictionary <string, FieldTypeWithHeuristics> fieldTypesByAutofillHint,
                                         Dictionary <string, FilledAutofillField> filledAutofillFieldsByTypeName,
                                         Dataset.Builder builder, MutableBoolean setValueAtLeastOnce)
        {
            var rawHints = viewNode.GetAutofillHints();

            if (rawHints == null || rawHints.Length == 0)
            {
                Util.Logv("No af hints at ViewNode - %s", viewNode.IdEntry);
                return;
            }
            string fieldTypeName = AutofillHints.GetFieldTypeNameFromAutofillHints(
                fieldTypesByAutofillHint, rawHints.ToList());

            if (fieldTypeName == null)
            {
                return;
            }
            FilledAutofillField field = filledAutofillFieldsByTypeName[fieldTypeName];

            if (field == null)
            {
                return;
            }
            BindValueToNode(viewNode, field, builder, setValueAtLeastOnce);
        }
コード例 #2
0
        /// <exception cref="System.Exception"/>
        public virtual void TestExpiry()
        {
            ShortCircuitCache cache = new ShortCircuitCache(2, 1, 1, 10000000, 1, 10000000, 0
                                                            );

            TestShortCircuitCache.TestFileDescriptorPair pair = new TestShortCircuitCache.TestFileDescriptorPair
                                                                    ();
            ShortCircuitReplicaInfo replicaInfo1 = cache.FetchOrCreate(new ExtendedBlockId(123
                                                                                           , "test_bp1"), new TestShortCircuitCache.SimpleReplicaCreator(123, cache, pair));

            Preconditions.CheckNotNull(replicaInfo1.GetReplica());
            Preconditions.CheckState(replicaInfo1.GetInvalidTokenException() == null);
            pair.CompareWith(replicaInfo1.GetReplica().GetDataStream(), replicaInfo1.GetReplica
                                 ().GetMetaStream());
            replicaInfo1.GetReplica().Unref();
            MutableBoolean triedToCreate = new MutableBoolean(false);

            do
            {
                Sharpen.Thread.Sleep(10);
                ShortCircuitReplicaInfo replicaInfo2 = cache.FetchOrCreate(new ExtendedBlockId(123
                                                                                               , "test_bp1"), new _ShortCircuitReplicaCreator_229(triedToCreate));
                if ((replicaInfo2 != null) && (replicaInfo2.GetReplica() != null))
                {
                    replicaInfo2.GetReplica().Unref();
                }
            }while (triedToCreate.IsFalse());
            cache.Close();
        }
コード例 #3
0
        public void Build(StringBuilder sb, IDictionary <String, Object> queryParamValues)
        {
            MutableBoolean isFirst = new MutableBoolean(true);

            foreach (String expression in expressions)
            {
                Append(sb, expression, isFirst);
            }

            foreach (Parameters sub in subParameters)
            {
                if (!(subParameters.Count == 0))
                {
                    Append(sb, "(", isFirst);
                    sub.Build(sb, queryParamValues);
                    sb.Append(")");
                }
            }

            foreach (Parameters negated in negatedParameters)
            {
                if (!(negatedParameters.Count == 0))
                {
                    Append(sb, "not (", isFirst);
                    negated.Build(sb, queryParamValues);
                    sb.Append(")");
                }
            }

            foreach (KeyValuePair <String, Object> pair in localQueryParamValues)
            {
                queryParamValues.Add(pair);
            }
        }
コード例 #4
0
            public bool Get()
            {
                MutableBoolean finished = new MutableBoolean(false);

                cache.Accept(new _CacheVisitor_410(finished));
                return(finished.BooleanValue());
            }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustUnblockPageFaultersWhenEvictionGetsException()
        internal virtual void MustUnblockPageFaultersWhenEvictionGetsException()
        {
            assertTimeout(ofMillis(SEMI_LONG_TIMEOUT_MILLIS), () =>
            {
                WriteInitialDataTo(file("a"));

                MutableBoolean throwException = new MutableBoolean(true);
                FileSystemAbstraction fs      = new DelegatingFileSystemAbstractionAnonymousInnerClass(this, this.fs, throwException);

                using (MuninnPageCache pageCache = createPageCache(fs, 2, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL), PagedFile pagedFile = map(pageCache, file("a"), 8))
                {
                    // The basic idea is that this loop, which will encounter a lot of page faults, must not block forever even
                    // though the eviction thread is unable to flush any dirty pages because the file system throws
                    // exceptions on all writes.
                    try
                    {
                        using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                        {
                            for (int i = 0; i < 1000; i++)
                            {
                                assertTrue(cursor.Next());
                            }
                            fail("Expected an exception at this point");
                        }
                    }
                    catch (IOException)
                    {
                        // Good.
                    }

                    throwException.setFalse();
                }
            });
コード例 #6
0
            public bool Get()
            {
                MutableBoolean result = new MutableBoolean(false);

                cache.Accept(new _CacheVisitor_687(expectedOutstandingMmaps, block, expectedIsAnchorable
                                                   , expectedIsAnchored, result));
                return(result.ToBoolean());
            }
コード例 #7
0
        private void Append(StringBuilder sb, String toAppend, MutableBoolean isFirst)
        {
            if (!isFirst.isSet())
            {
                sb.Append(" ").Append(connective).Append(" ");
            }

            sb.Append(toAppend);

            isFirst.unset();
        }
コード例 #8
0
        /// <exception cref="System.Exception"/>
        public virtual void TestEviction()
        {
            ShortCircuitCache cache = new ShortCircuitCache(2, 10000000, 1, 10000000, 1, 10000
                                                            , 0);

            TestShortCircuitCache.TestFileDescriptorPair[] pairs = new TestShortCircuitCache.TestFileDescriptorPair
                                                                   [] { new TestShortCircuitCache.TestFileDescriptorPair(), new TestShortCircuitCache.TestFileDescriptorPair
                                                                            (), new TestShortCircuitCache.TestFileDescriptorPair() };
            ShortCircuitReplicaInfo[] replicaInfos = new ShortCircuitReplicaInfo[] { null, null
                                                                                     , null };
            for (int i = 0; i < pairs.Length; i++)
            {
                replicaInfos[i] = cache.FetchOrCreate(new ExtendedBlockId(i, "test_bp1"), new TestShortCircuitCache.SimpleReplicaCreator
                                                          (i, cache, pairs[i]));
                Preconditions.CheckNotNull(replicaInfos[i].GetReplica());
                Preconditions.CheckState(replicaInfos[i].GetInvalidTokenException() == null);
                pairs[i].CompareWith(replicaInfos[i].GetReplica().GetDataStream(), replicaInfos[i
                                     ].GetReplica().GetMetaStream());
            }
            // At this point, we have 3 replicas in use.
            // Let's close them all.
            for (int i_1 = 0; i_1 < pairs.Length; i_1++)
            {
                replicaInfos[i_1].GetReplica().Unref();
            }
            // The last two replicas should still be cached.
            for (int i_2 = 1; i_2 < pairs.Length; i_2++)
            {
                int iVal = i_2;
                replicaInfos[i_2] = cache.FetchOrCreate(new ExtendedBlockId(i_2, "test_bp1"), new
                                                        _ShortCircuitReplicaCreator_277(iVal));
                Preconditions.CheckNotNull(replicaInfos[i_2].GetReplica());
                Preconditions.CheckState(replicaInfos[i_2].GetInvalidTokenException() == null);
                pairs[i_2].CompareWith(replicaInfos[i_2].GetReplica().GetDataStream(), replicaInfos
                                       [i_2].GetReplica().GetMetaStream());
            }
            // The first (oldest) replica should not be cached.
            MutableBoolean calledCreate = new MutableBoolean(false);

            replicaInfos[0] = cache.FetchOrCreate(new ExtendedBlockId(0, "test_bp1"), new _ShortCircuitReplicaCreator_293
                                                      (calledCreate));
            Preconditions.CheckState(replicaInfos[0].GetReplica() == null);
            NUnit.Framework.Assert.IsTrue(calledCreate.IsTrue());
            // Clean up
            for (int i_3 = 1; i_3 < pairs.Length; i_3++)
            {
                replicaInfos[i_3].GetReplica().Unref();
            }
            for (int i_4 = 0; i_4 < pairs.Length; i_4++)
            {
                pairs[i_4].Close();
            }
            cache.Close();
        }
コード例 #9
0
ファイル: LabelScanStoreTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void forceShouldNotCheckpointTreeOnReadOnlyScanStore()
        public virtual void ForceShouldNotCheckpointTreeOnReadOnlyScanStore()
        {
            MutableBoolean ioLimiterCalled = new MutableBoolean();

            CreateAndStartReadOnly();
            _store.force((previousStamp, recentlyCompletedIOs, flushable) =>
            {
                ioLimiterCalled.setTrue();
                return(0);
            });
            assertFalse(ioLimiterCalled.Value);
        }
コード例 #10
0
        private bool BindDatasetToFocusedNode(FilledAutofillField field, FieldType fieldType, Dataset.Builder builder)
        {
            MutableBoolean setValueAtLeastOnce = new MutableBoolean(false);

            mClientParser.Parse(new BindDatasetToFocusedNodeProcessor()
            {
                field               = field,
                builder             = builder,
                datasetAdapter      = this,
                setValueAtLeastOnce = setValueAtLeastOnce
            });
            return(setValueAtLeastOnce.Value);
        }
コード例 #11
0
            public bool Get()
            {
                MutableBoolean done = new MutableBoolean(false);

                try
                {
                    cache.GetDfsClientShmManager().Visit(new _Visitor_463(done, datanode));
                }
                catch (IOException e)
                {
                    TestShortCircuitCache.Log.Error("error running visitor", e);
                }
                return(done.BooleanValue());
            }
コード例 #12
0
        /// <returns> true if instantiated tree needs to be rebuilt. </returns>
        private bool InstantiateTree()
        {
            _monitors.addMonitorListener(TreeMonitor());
            GBPTree.Monitor monitor      = _monitors.newMonitor(typeof(GBPTree.Monitor));
            MutableBoolean  isRebuilding = new MutableBoolean();

            Header.Reader readRebuilding = headerData => isRebuilding.setValue(headerData.get() == _needsRebuilding);
            try
            {
                _index = new GBPTree <LabelScanKey, LabelScanValue>(_pageCache, _storeFile, new LabelScanLayout(), _pageSize, monitor, readRebuilding, _needsRebuildingWriter, _recoveryCleanupWorkCollector, _readOnly);
                return(isRebuilding.Value);
            }
            catch (TreeFileNotFoundException e)
            {
                throw new System.InvalidOperationException("Label scan store file could not be found, most likely this database needs to be recovered, file:" + _storeFile, e);
            }
        }
コード例 #13
0
 internal DirectionData(ShortestPath outerInstance, Node startNode, ICollection <long> sharedVisitedRels, MutableInt sharedFrozenDepth, MutableBoolean sharedStop, MutableInt sharedCurrentDepth, PathExpander expander)
 {
     this._outerInstance          = outerInstance;
     this.StartNode               = startNode;
     this.VisitedNodes[startNode] = new LevelData(null, 0);
     this.NextNodes.Add(startNode);
     this.SharedFrozenDepth  = sharedFrozenDepth;
     this.SharedStop         = sharedStop;
     this.SharedCurrentDepth = sharedCurrentDepth;
     this.Expander           = expander;
     this.SharedVisitedRels  = sharedVisitedRels;
     this.LastPath           = new DirectionDataPath(startNode);
     if (sharedCurrentDepth.intValue() < outerInstance.maxDepth)
     {
         PrepareNextLevel();
     }
     else
     {
         this.NextRelationships = Iterators.emptyResourceIterator();
     }
 }
コード例 #14
0
ファイル: SchemaLayouts.cs プロジェクト: Neo4Net/Neo4Net
 private static LayoutBootstrapper SpatialLayoutFactory(CoordinateReferenceSystem crs)
 {
     return((indexFile, pageCache, meta, targetLayout) =>
     {
         if (targetLayout.Equals(crs.Name))
         {
             MutableBoolean failure = new MutableBoolean(false);
             Function <ByteBuffer, string> onError = byteBuffer =>
             {
                 failure.setTrue();
                 return "";
             };
             SpaceFillingCurveSettings curveSettings = SpaceFillingCurveSettingsFactory.fromGBPTree(indexFile, pageCache, onError);
             if (!failure.Value)
             {
                 return new SpatialLayout(crs, curveSettings.curve());
             }
         }
         return null;
     });
 }
コード例 #15
0
        /**
         * Build an autofill {@link Dataset} using saved data and the client's AssistStructure.
         */
        private bool BindDataset(Dictionary <string, FieldTypeWithHeuristics> fieldTypesByAutofillHint,
                                 DatasetWithFilledAutofillFields datasetWithFilledAutofillFields,
                                 Dataset.Builder datasetBuilder)
        {
            MutableBoolean setValueAtLeastOnce = new MutableBoolean(false);

            var filledAutofillFieldsByTypeName =
                datasetWithFilledAutofillFields
                .filledAutofillFields
                .ToDictionary(x => x.GetFieldTypeName(), x => x);

            mClientParser.Parse(new BindDatasetNodeProcessor
            {
                datasetBuilder                 = datasetBuilder,
                setValueAtLeastOnce            = setValueAtLeastOnce,
                fieldTypesByAutofillHint       = fieldTypesByAutofillHint,
                filledAutofillFieldsByTypeName = filledAutofillFieldsByTypeName,
                datasetAdapter                 = this
            });

            return(setValueAtLeastOnce.Value);
        }
コード例 #16
0
 /// <exception cref="System.IO.IOException"/>
 public virtual ShortCircuitShm.Slot AllocSlot(DatanodeInfo datanode, DomainPeer peer
                                               , MutableBoolean usedPeer, ExtendedBlockId blockId, string clientName)
 {
     Lock.Lock();
     try
     {
         if (closed)
         {
             Log.Trace(this + ": the DfsClientShmManager isclosed.");
             return(null);
         }
         DfsClientShmManager.EndpointShmManager shmManager = datanodes[datanode];
         if (shmManager == null)
         {
             shmManager          = new DfsClientShmManager.EndpointShmManager(this, datanode);
             datanodes[datanode] = shmManager;
         }
         return(shmManager.AllocSlot(peer, usedPeer, clientName, blockId));
     }
     finally
     {
         Lock.Unlock();
     }
 }
コード例 #17
0
        private IEnumerable <Path> InternalPaths(Node start, Node end, bool stopAsap)
        {
            _lastMetadata = new Metadata();
            if (start.Equals(end))
            {
                return(FilterPaths(Collections.singletonList(PathImpl.singular(start))));
            }
            Hits hits = new Hits();
            ICollection <long> sharedVisitedRels  = new HashSet <long>();
            MutableInt         sharedFrozenDepth  = new MutableInt(Null);        // ShortestPathLengthSoFar
            MutableBoolean     sharedStop         = new MutableBoolean();
            MutableInt         sharedCurrentDepth = new MutableInt(0);

            using (DirectionData startData = new DirectionData(this, start, sharedVisitedRels, sharedFrozenDepth, sharedStop, sharedCurrentDepth, _expander), DirectionData endData = new DirectionData(this, end, sharedVisitedRels, sharedFrozenDepth, sharedStop, sharedCurrentDepth, _expander.reverse()))
            {
                while (startData.MoveNext() || endData.MoveNext())
                {
                    GoOneStep(startData, endData, hits, startData, stopAsap);
                    GoOneStep(endData, startData, hits, startData, stopAsap);
                }
                ICollection <Hit> least = hits.Least();
                return(least != null?FilterPaths(HitsToPaths( least, start, end, stopAsap, _maxResultCount )) : Collections.emptyList());
            }
        }
コード例 #18
0
        /// <exception cref="System.Exception"/>
        public virtual void TestAllocShm()
        {
            BlockReaderTestUtil.EnableShortCircuitShmTracing();
            TemporarySocketDirectory sockDir = new TemporarySocketDirectory();
            Configuration            conf    = CreateShortCircuitConf("testAllocShm", sockDir);
            MiniDFSCluster           cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(1).Build();

            cluster.WaitActive();
            DistributedFileSystem fs    = cluster.GetFileSystem();
            ShortCircuitCache     cache = fs.GetClient().GetClientContext().GetShortCircuitCache(
                );

            cache.GetDfsClientShmManager().Visit(new _Visitor_423());
            // The ClientShmManager starts off empty
            DomainPeer      peer     = GetDomainPeerToDn(conf);
            MutableBoolean  usedPeer = new MutableBoolean(false);
            ExtendedBlockId blockId  = new ExtendedBlockId(123, "xyz");
            DatanodeInfo    datanode = new DatanodeInfo(cluster.GetDataNodes()[0].GetDatanodeId(
                                                            ));

            // Allocating the first shm slot requires using up a peer.
            ShortCircuitShm.Slot slot = cache.AllocShmSlot(datanode, peer, usedPeer, blockId,
                                                           "testAllocShm_client");
            NUnit.Framework.Assert.IsNotNull(slot);
            NUnit.Framework.Assert.IsTrue(usedPeer.BooleanValue());
            cache.GetDfsClientShmManager().Visit(new _Visitor_441(datanode));
            // The ClientShmManager starts off empty
            cache.ScheduleSlotReleaser(slot);
            // Wait for the slot to be released, and the shared memory area to be
            // closed.  Since we didn't register this shared memory segment on the
            // server, it will also be a test of how well the server deals with
            // bogus client behavior.
            GenericTestUtils.WaitFor(new _Supplier_458(cache, datanode), 10, 60000);
            cluster.Shutdown();
            sockDir.Close();
        }
コード例 #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseStoreFileOnFailureToOpen()
        public virtual void ShouldCloseStoreFileOnFailureToOpen()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableBoolean fired = new org.apache.commons.lang3.mutable.MutableBoolean();
            MutableBoolean        fired = new MutableBoolean();
            FileSystemAbstraction fs    = new DelegatingFileSystemAbstractionAnonymousInnerClass(this, _efs.get(), fired);

            // WHEN
            try
            {
                using (PageCache pageCache = PageCacheRule.getPageCache(fs))
                {
                    NewNodeStore(fs);
                    fail("Should fail");
                }
            }               // Close the page cache here so that we can see failure to close (due to still mapped files)
            catch (Exception e)
            {
                // THEN
                assertTrue(contains(e, typeof(IOException)));
                assertTrue(fired.booleanValue());
            }
        }
コード例 #20
0
 public _Visitor_463(MutableBoolean done, DatanodeInfo datanode)
 {
     this.done     = done;
     this.datanode = datanode;
 }
コード例 #21
0
 public _CacheVisitor_410(MutableBoolean finished)
 {
     this.finished = finished;
 }
コード例 #22
0
 public _ShortCircuitReplicaCreator_293(MutableBoolean calledCreate)
 {
     this.calledCreate = calledCreate;
 }
コード例 #23
0
 public _CacheVisitor_687(int expectedOutstandingMmaps, ExtendedBlock block, bool
                          expectedIsAnchorable, bool expectedIsAnchored, MutableBoolean result)
 {
     this.expectedOutstandingMmaps = expectedOutstandingMmaps;
     this.block = block;
     this.expectedIsAnchorable = expectedIsAnchorable;
     this.expectedIsAnchored   = expectedIsAnchored;
     this.result = result;
 }
コード例 #24
0
 public _ShortCircuitReplicaCreator_229(MutableBoolean triedToCreate)
 {
     this.triedToCreate = triedToCreate;
 }
コード例 #25
0
        void BindValueToNode(AssistStructure.ViewNode viewNode,
                             FilledAutofillField field, Dataset.Builder builder,
                             MutableBoolean setValueAtLeastOnce)
        {
            AutofillId autofillId = viewNode.AutofillId;

            if (autofillId == null)
            {
                Util.Logw("Autofill ID null for %s", viewNode.ToString());
                return;
            }
            int autofillType = (int)viewNode.AutofillType;

            switch (autofillType)
            {
            case (int)AutofillType.List:
                var options   = viewNode.GetAutofillOptions();
                int listValue = -1;
                if (options != null)
                {
                    listValue = Util.IndexOf(viewNode.GetAutofillOptions(), field.GetTextValue());
                }
                if (listValue != -1)
                {
                    builder.SetValue(autofillId, AutofillValue.ForList(listValue));
                    setValueAtLeastOnce.Value = true;
                }
                break;

            case (int)AutofillType.Date:
                var dateValue = field.GetDateValue();
                if (dateValue != null)
                {
                    builder.SetValue(autofillId, AutofillValue.ForDate(dateValue));
                    setValueAtLeastOnce.Value = true;
                }
                break;

            case (int)AutofillType.Text:
                string textValue = field.GetTextValue();
                if (textValue != null)
                {
                    builder.SetValue(autofillId, AutofillValue.ForText(textValue));
                    setValueAtLeastOnce.Value = true;
                }
                break;

            case (int)AutofillType.Toggle:
                var toggleValue = field.GetToggleValue();
                if (toggleValue != null)
                {
                    builder.SetValue(autofillId, AutofillValue.ForToggle(toggleValue));
                    setValueAtLeastOnce.Value = true;
                }
                break;

            case (int)AutofillType.None:
                break;

            default:
                Util.Logw("Invalid autofill type - %d", autofillType);
                break;
            }
        }
コード例 #26
0
 public DelegatingFileSystemAbstractionAnonymousInnerClass(NodeStoreTest outerInstance, UnknownType get, MutableBoolean fired) : base(get)
 {
     this.outerInstance = outerInstance;
     this._fired        = fired;
 }
コード例 #27
0
 public DelegatingFileSystemAbstractionAnonymousInnerClass2(MuninnPageCacheTest outerInstance, UnknownType fs, MutableBoolean throwException) : base(fs)
 {
     this.outerInstance   = outerInstance;
     this._throwException = throwException;
 }
コード例 #28
0
    private void Append(StringBuilder sb, String toAppend, MutableBoolean isFirst) {
        if (!isFirst.isSet()) {
            sb.Append(" ").Append(connective).Append(" ");
        }

        sb.Append(toAppend);

        isFirst.unset();
    }
コード例 #29
0
 /// <summary>Allocate a new shared memory slot connected to this datanode.</summary>
 /// <remarks>
 /// Allocate a new shared memory slot connected to this datanode.
 /// Must be called with the EndpointShmManager lock held.
 /// </remarks>
 /// <param name="peer">The peer to use to talk to the DataNode.</param>
 /// <param name="usedPeer">
 /// (out param) Will be set to true if we used the peer.
 /// When a peer is used
 /// </param>
 /// <param name="clientName">The client name.</param>
 /// <param name="blockId">The block ID to use.</param>
 /// <returns>
 /// null if the DataNode does not support shared memory
 /// segments, or experienced an error creating the
 /// shm.  The shared memory segment itself on success.
 /// </returns>
 /// <exception cref="System.IO.IOException">If there was an error communicating over the socket.
 ///     </exception>
 internal virtual ShortCircuitShm.Slot AllocSlot(DomainPeer peer, MutableBoolean usedPeer
                                                 , string clientName, ExtendedBlockId blockId)
 {
     while (true)
     {
         if (this._enclosing.closed)
         {
             if (DfsClientShmManager.Log.IsTraceEnabled())
             {
                 DfsClientShmManager.Log.Trace(this + ": the DfsClientShmManager has been closed."
                                               );
             }
             return(null);
         }
         if (this.disabled)
         {
             if (DfsClientShmManager.Log.IsTraceEnabled())
             {
                 DfsClientShmManager.Log.Trace(this + ": shared memory segment access is disabled."
                                               );
             }
             return(null);
         }
         // Try to use an existing slot.
         ShortCircuitShm.Slot slot = this.AllocSlotFromExistingShm(blockId);
         if (slot != null)
         {
             return(slot);
         }
         // There are no free slots.  If someone is loading more slots, wait
         // for that to finish.
         if (this.loading)
         {
             if (DfsClientShmManager.Log.IsTraceEnabled())
             {
                 DfsClientShmManager.Log.Trace(this + ": waiting for loading to finish...");
             }
             this._enclosing.finishedLoading.AwaitUninterruptibly();
         }
         else
         {
             // Otherwise, load the slot ourselves.
             this.loading = true;
             this._enclosing.Lock.Unlock();
             DfsClientShm shm;
             try
             {
                 shm = this.RequestNewShm(clientName, peer);
                 if (shm == null)
                 {
                     continue;
                 }
                 // See #{DfsClientShmManager#domainSocketWatcher} for details
                 // about why we do this before retaking the manager lock.
                 this._enclosing.domainSocketWatcher.Add(peer.GetDomainSocket(), shm);
                 // The DomainPeer is now our responsibility, and should not be
                 // closed by the caller.
                 usedPeer.SetValue(true);
             }
             finally
             {
                 this._enclosing.Lock.Lock();
                 this.loading = false;
                 this._enclosing.finishedLoading.SignalAll();
             }
             if (shm.IsDisconnected())
             {
                 // If the peer closed immediately after the shared memory segment
                 // was created, the DomainSocketWatcher callback might already have
                 // fired and marked the shm as disconnected.  In this case, we
                 // obviously don't want to add the SharedMemorySegment to our list
                 // of valid not-full segments.
                 if (DfsClientShmManager.Log.IsDebugEnabled())
                 {
                     DfsClientShmManager.Log.Debug(this + ": the UNIX domain socket associated with "
                                                   + "this short-circuit memory closed before we could make " + "use of the shm.");
                 }
             }
             else
             {
                 this.notFull[shm.GetShmId()] = shm;
             }
         }
     }
 }
コード例 #30
0
    public void Build(StringBuilder sb, IDictionary<String, Object> queryParamValues) {
        MutableBoolean isFirst = new MutableBoolean(true);

        foreach (String expression in expressions) {
            Append(sb, expression, isFirst);
        }

        foreach (Parameters sub in subParameters) {
            if (!(subParameters.Count == 0)) {
                Append(sb, "(", isFirst);
                sub.Build(sb, queryParamValues);
                sb.Append(")");
            }
        }

        foreach (Parameters negated in negatedParameters) {
            if (!(negatedParameters.Count == 0)) {
                Append(sb, "not (", isFirst);
                negated.Build(sb, queryParamValues);
                sb.Append(")");
            }
        }

        foreach (KeyValuePair<String, Object> pair in localQueryParamValues)
        {
            queryParamValues.Add(pair);
        }
    }
コード例 #31
0
 /// <summary>Fetch a pair of short-circuit block descriptors from a local DataNode.</summary>
 /// <returns>
 /// Null if we could not communicate with the datanode,
 /// a new ShortCircuitReplicaInfo object otherwise.
 /// ShortCircuitReplicaInfo objects may contain either an InvalidToken
 /// exception, or a ShortCircuitReplica object ready to use.
 /// </returns>
 public virtual ShortCircuitReplicaInfo CreateShortCircuitReplicaInfo()
 {
     if (createShortCircuitReplicaInfoCallback != null)
     {
         ShortCircuitReplicaInfo info = createShortCircuitReplicaInfoCallback.CreateShortCircuitReplicaInfo
                                            ();
         if (info != null)
         {
             return(info);
         }
     }
     if (Log.IsTraceEnabled())
     {
         Log.Trace(this + ": trying to create ShortCircuitReplicaInfo.");
     }
     BlockReaderFactory.BlockReaderPeer curPeer;
     while (true)
     {
         curPeer = NextDomainPeer();
         if (curPeer == null)
         {
             break;
         }
         if (curPeer.fromCache)
         {
             remainingCacheTries--;
         }
         DomainPeer           peer  = (DomainPeer)curPeer.peer;
         ShortCircuitShm.Slot slot  = null;
         ShortCircuitCache    cache = clientContext.GetShortCircuitCache();
         try
         {
             MutableBoolean usedPeer = new MutableBoolean(false);
             slot = cache.AllocShmSlot(datanode, peer, usedPeer, new ExtendedBlockId(block.GetBlockId
                                                                                         (), block.GetBlockPoolId()), clientName);
             if (usedPeer.BooleanValue())
             {
                 if (Log.IsTraceEnabled())
                 {
                     Log.Trace(this + ": allocShmSlot used up our previous socket " + peer.GetDomainSocket
                                   () + ".  Allocating a new one...");
                 }
                 curPeer = NextDomainPeer();
                 if (curPeer == null)
                 {
                     break;
                 }
                 peer = (DomainPeer)curPeer.peer;
             }
             ShortCircuitReplicaInfo info = RequestFileDescriptors(peer, slot);
             clientContext.GetPeerCache().Put(datanode, peer);
             return(info);
         }
         catch (IOException e)
         {
             if (slot != null)
             {
                 cache.FreeSlot(slot);
             }
             if (curPeer.fromCache)
             {
                 // Handle an I/O error we got when using a cached socket.
                 // These are considered less serious, because the socket may be stale.
                 if (Log.IsDebugEnabled())
                 {
                     Log.Debug(this + ": closing stale domain peer " + peer, e);
                 }
                 IOUtils.Cleanup(Log, peer);
             }
             else
             {
                 // Handle an I/O error we got when using a newly created socket.
                 // We temporarily disable the domain socket path for a few minutes in
                 // this case, to prevent wasting more time on it.
                 Log.Warn(this + ": I/O error requesting file descriptors.  " + "Disabling domain socket "
                          + peer.GetDomainSocket(), e);
                 IOUtils.Cleanup(Log, peer);
                 clientContext.GetDomainSocketFactory().DisableDomainSocketPath(pathInfo.GetPath()
                                                                                );
                 return(null);
             }
         }
     }
     return(null);
 }