private void AddResourceRequest(Priority priority, IDictionary <string, ResourceRequest > requests, string resourceName, Org.Apache.Hadoop.Yarn.Api.Records.Resource capability ) { lock (this) { ResourceRequest request = requests[resourceName]; if (request == null) { request = BuilderUtils.NewResourceRequest(priority, resourceName, capability, 1); requests[resourceName] = request; } else { request.SetNumContainers(request.GetNumContainers() + 1); } // Note this down for next interaction with ResourceManager ask.Remove(request); ask.AddItem(BuilderUtils.NewResourceRequest(request)); // clone to ensure the RM doesn't manipulate the same obj if (Log.IsDebugEnabled()) { Log.Debug("addResourceRequest: applicationId=" + applicationId.GetId() + " priority=" + priority.GetPriority() + " resourceName=" + resourceName + " capability=" + capability + " numContainers=" + request.GetNumContainers() + " #asks=" + ask.Count); } } }
public virtual Graph NewSubGraph(string name) { Graph ret = new Graph(name, this); subgraphs.AddItem(ret); return(ret); }
static AmazonS3() { SIGNED_HEADERS = new HashSet <string>(); SIGNED_HEADERS.AddItem("content-type"); SIGNED_HEADERS.AddItem("content-md5"); SIGNED_HEADERS.AddItem("date"); }
private void ApplyRequestLimits() { IEnumerator <ResourceRequest> iter = requestLimits.Values.GetEnumerator(); while (iter.HasNext()) { ResourceRequest reqLimit = iter.Next(); int limit = reqLimit.GetNumContainers(); IDictionary <string, IDictionary <Resource, ResourceRequest> > remoteRequests = remoteRequestsTable [reqLimit.GetPriority()]; IDictionary <Resource, ResourceRequest> reqMap = (remoteRequests != null) ? remoteRequests [ResourceRequest.Any] : null; ResourceRequest req = (reqMap != null) ? reqMap[reqLimit.GetCapability()] : null; if (req == null) { continue; } // update an existing ask or send a new one if updating if (ask.Remove(req) || requestLimitsToUpdate.Contains(req)) { ResourceRequest newReq = req.GetNumContainers() > limit ? reqLimit : req; ask.AddItem(newReq); Log.Info("Applying ask limit of " + newReq.GetNumContainers() + " for priority:" + reqLimit.GetPriority() + " and capability:" + reqLimit.GetCapability()); } if (limit == int.MaxValue) { iter.Remove(); } } requestLimitsToUpdate.Clear(); }
public virtual void TestReloadTurnsLeafQueueIntoParent() { UpdateConfiguredLeafQueues(queueManager, "queue1"); // When no apps are running in the leaf queue, should be fine turning it // into a parent. UpdateConfiguredLeafQueues(queueManager, "queue1.queue2"); NUnit.Framework.Assert.IsNull(queueManager.GetLeafQueue("queue1", false)); NUnit.Framework.Assert.IsNotNull(queueManager.GetLeafQueue("queue1.queue2", false )); // When leaf queues are empty, should be ok deleting them and // turning parent into a leaf. UpdateConfiguredLeafQueues(queueManager, "queue1"); NUnit.Framework.Assert.IsNull(queueManager.GetLeafQueue("queue1.queue2", false)); NUnit.Framework.Assert.IsNotNull(queueManager.GetLeafQueue("queue1", false)); // When apps exist in leaf queue, we shouldn't be able to create // children under it, but things should work otherwise. notEmptyQueues.AddItem(queueManager.GetLeafQueue("queue1", false)); UpdateConfiguredLeafQueues(queueManager, "queue1.queue2"); NUnit.Framework.Assert.IsNull(queueManager.GetLeafQueue("queue1.queue2", false)); NUnit.Framework.Assert.IsNotNull(queueManager.GetLeafQueue("queue1", false)); // When apps exist in leaf queues under a parent queue, shouldn't be // able to turn it into a leaf queue, but things should work otherwise. notEmptyQueues.Clear(); UpdateConfiguredLeafQueues(queueManager, "queue1.queue2"); notEmptyQueues.AddItem(queueManager.GetQueue("root.queue1")); UpdateConfiguredLeafQueues(queueManager, "queue1"); NUnit.Framework.Assert.IsNotNull(queueManager.GetLeafQueue("queue1.queue2", false )); NUnit.Framework.Assert.IsNull(queueManager.GetLeafQueue("queue1", false)); // Should never to be able to create a queue under the default queue UpdateConfiguredLeafQueues(queueManager, "default.queue3"); NUnit.Framework.Assert.IsNull(queueManager.GetLeafQueue("default.queue3", false)); NUnit.Framework.Assert.IsNotNull(queueManager.GetLeafQueue("default", false)); }
static DelegationTokenAuthenticationHandler() { DelegationTokenOps.AddItem(DelegationTokenAuthenticator.DelegationTokenOperation. Getdelegationtoken.ToString()); DelegationTokenOps.AddItem(DelegationTokenAuthenticator.DelegationTokenOperation. Renewdelegationtoken.ToString()); DelegationTokenOps.AddItem(DelegationTokenAuthenticator.DelegationTokenOperation. Canceldelegationtoken.ToString()); }
/// <summary>Include a single ref (a name/object pair) in the bundle.</summary> /// <remarks> /// Include a single ref (a name/object pair) in the bundle. /// <p> /// This is a utility function for: /// <code>include(r.getName(), r.getObjectId())</code>. /// </remarks> /// <param name="r">the ref to include.</param> public virtual void Include(Ref r) { Include(r.GetName(), r.GetObjectId()); if (r.GetPeeledObjectId() != null) { tagTargets.AddItem(r.GetPeeledObjectId()); } else { if (r.GetObjectId() != null && r.GetName().StartsWith(Constants.R_HEADS)) { tagTargets.AddItem(r.GetObjectId()); } } }
private static void ValidateStates(string stateQuery, ICollection <string> statesQuery ) { // stateQuery is deprecated. if (stateQuery != null && !stateQuery.IsEmpty()) { statesQuery.AddItem(stateQuery); } ICollection <string> appStates = ParseQueries(statesQuery, true); foreach (string appState in appStates) { switch (YarnApplicationState.ValueOf(StringUtils.ToUpperCase(appState))) { case YarnApplicationState.Finished: case YarnApplicationState.Failed: case YarnApplicationState.Killed: { continue; } default: { throw new BadRequestException("Invalid application-state " + appState + " specified. It should be a final state" ); } } } }
internal virtual void AddValue(int blockIndex, long value) { if (blockIds.AddItem(blockIndex) == true) { this.value += value; } }
/// <exception cref="System.IO.IOException"></exception> private bool CurrentRowMatchesEntryImpl(object[] rowValues) { if (_indexEntryPattern == null) { // init our set of index column names _indexEntryPattern = new HashSet <string>(); foreach (IndexData.ColumnDescriptor col in GetIndex().GetColumns()) { _indexEntryPattern.AddItem(col.GetName()); } } // check the next row to see if it actually matches IDictionary <string, object> row = GetCurrentRow(_indexEntryPattern); foreach (IndexData.ColumnDescriptor col_1 in GetIndex().GetColumns()) { string columnName = col_1.GetName(); object patValue = rowValues[col_1.GetColumnIndex()]; object rowValue = row.Get(columnName); if (!_columnMatcher.Matches(GetTable(), columnName, patValue, rowValue)) { return(false); } } return(true); }
/// <summary>Add all nodes from a dependent nodes list to excludedNodes.</summary> /// <returns>number of new excluded nodes</returns> private int AddDependentNodesToExcludedNodes(DatanodeDescriptor chosenNode, ICollection <Node> excludedNodes) { if (this.host2datanodeMap == null) { return(0); } int countOfExcludedNodes = 0; foreach (string hostname in chosenNode.GetDependentHostNames()) { DatanodeDescriptor node = this.host2datanodeMap.GetDataNodeByHostName(hostname); if (node != null) { if (excludedNodes.AddItem(node)) { countOfExcludedNodes++; } } else { Log.Warn("Not able to find datanode " + hostname + " which has dependency with datanode " + chosenNode.GetHostName()); } } return(countOfExcludedNodes); }
private Func <PropertyEditorItem, bool> InsertScalarProperty(ICollection <PropertyEditorItem> propertyItems, PropertyEditor propertyEditor) { return(propertyItem => { if (propertyItem != null) { var propertyValue = propertyItem.Item; if (propertyValue != null) { dynamic editValue = EditValue; if (editValue != null) { // Установка значения свойства редактируемого объекта var wrapPropertyValue = WrapPropertyValue(propertyEditor, propertyValue); editValue[propertyEditor.Property] = wrapPropertyValue; // Добавление свойства в коллекцию визуального элемента var newPropertyItem = CreatePropertyItem(propertyEditor, propertyValue); propertyItems.AddItem(newPropertyItem); SetSelectedProperty(newPropertyItem); return true; } } } return false; }); }
//Add attempt to a given Task. protected internal virtual void AddSpeculativeAttempt(TaskId taskID) { Log.Info("DefaultSpeculator.addSpeculativeAttempt -- we are speculating " + taskID ); eventHandler.Handle(new TaskEvent(taskID, TaskEventType.TAddSpecAttempt)); mayHaveSpeculated.AddItem(taskID); }
/// <exception cref="System.IO.IOException"/> public virtual void ReadFields(DataInput @in) { numActiveTrackers = @in.ReadInt(); int numTrackerNames = @in.ReadInt(); if (numTrackerNames > 0) { for (int i = 0; i < numTrackerNames; i++) { string name = StringInterner.WeakIntern(Org.Apache.Hadoop.IO.Text.ReadString(@in) ); activeTrackers.AddItem(name); } } numBlacklistedTrackers = @in.ReadInt(); int blackListTrackerInfoSize = @in.ReadInt(); if (blackListTrackerInfoSize > 0) { for (int i = 0; i < blackListTrackerInfoSize; i++) { ClusterStatus.BlackListInfo info = new ClusterStatus.BlackListInfo(); info.ReadFields(@in); blacklistedTrackersInfo.AddItem(info); } } numExcludedNodes = @in.ReadInt(); ttExpiryInterval = @in.ReadLong(); map_tasks = @in.ReadInt(); reduce_tasks = @in.ReadInt(); max_map_tasks = @in.ReadInt(); max_reduce_tasks = @in.ReadInt(); status = WritableUtils.ReadEnum <Cluster.JobTrackerStatus>(@in); grayListedTrackers = @in.ReadInt(); }
/// <exception cref="System.IO.IOException"/> public virtual void ReadFields(DataInput @in) { this.taskid.ReadFields(@in); this.progress = @in.ReadFloat(); this.state = StringInterner.WeakIntern(Text.ReadString(@in)); this.startTime = @in.ReadLong(); this.finishTime = @in.ReadLong(); diagnostics = WritableUtils.ReadStringArray(@in); counters = new Counters(); counters.ReadFields(@in); currentStatus = WritableUtils.ReadEnum <TIPStatus>(@in); if (currentStatus == TIPStatus.Running) { int num = WritableUtils.ReadVInt(@in); for (int i = 0; i < num; i++) { TaskAttemptID t = new TaskAttemptID(); t.ReadFields(@in); runningAttempts.AddItem(t); } } else { if (currentStatus == TIPStatus.Complete) { successfulAttempt.ReadFields(@in); } } }
private void AddToSet(ICollection <string> set, string[] array) { foreach (string s in array) { set.AddItem(s); } }
// Set up fault injection mock. /// <summary> /// Run through the creation of a log without any faults injected, /// and count how many RPCs are made to each node. /// </summary> /// <remarks> /// Run through the creation of a log without any faults injected, /// and count how many RPCs are made to each node. This sets the /// bounds for the other test cases, so they can exhaustively explore /// the space of potential failures. /// </remarks> /// <exception cref="System.Exception"/> private static long DetermineMaxIpcNumber() { Configuration conf = new Configuration(); MiniJournalCluster cluster = new MiniJournalCluster.Builder(conf).Build(); QuorumJournalManager qjm = null; long ret; try { qjm = CreateInjectableQJM(cluster); qjm.Format(QJMTestUtil.FakeNsinfo); DoWorkload(cluster, qjm); ICollection <int> ipcCounts = Sets.NewTreeSet(); foreach (AsyncLogger l in qjm.GetLoggerSetForTests().GetLoggersForTests()) { TestQJMWithFaults.InvocationCountingChannel ch = (TestQJMWithFaults.InvocationCountingChannel )l; ch.WaitForAllPendingCalls(); ipcCounts.AddItem(ch.GetRpcCount()); } // All of the loggers should have sent the same number of RPCs, since there // were no failures. NUnit.Framework.Assert.AreEqual(1, ipcCounts.Count); ret = ipcCounts.First(); Log.Info("Max IPC count = " + ret); } finally { IOUtils.CloseStream(qjm); cluster.Shutdown(); } return(ret); }
/// <summary>Assume a commit is available on the recipient's side.</summary> /// <remarks> /// Assume a commit is available on the recipient's side. /// <p> /// In order to fetch from a bundle the recipient must have any assumed /// commit. Each assumed commit is explicitly recorded in the bundle header /// to permit the recipient to validate it has these objects. /// </remarks> /// <param name="c"> /// the commit to assume being available. This commit should be /// parsed and not disposed in order to maximize the amount of /// debugging information available in the bundle stream. /// </param> public virtual void Assume(RevCommit c) { if (c != null) { assume.AddItem(c); } }
public FairSchedulerQueueInfo(FSQueue queue, FairScheduler scheduler) { AllocationConfiguration allocConf = scheduler.GetAllocationConfiguration(); queueName = queue.GetName(); schedulingPolicy = queue.GetPolicy().GetName(); clusterResources = new ResourceInfo(scheduler.GetClusterResource()); usedResources = new ResourceInfo(queue.GetResourceUsage()); fractionMemUsed = (float)usedResources.GetMemory() / clusterResources.GetMemory(); steadyFairResources = new ResourceInfo(queue.GetSteadyFairShare()); fairResources = new ResourceInfo(queue.GetFairShare()); minResources = new ResourceInfo(queue.GetMinShare()); maxResources = new ResourceInfo(queue.GetMaxShare()); maxResources = new ResourceInfo(Resources.ComponentwiseMin(queue.GetMaxShare(), scheduler .GetClusterResource())); fractionMemSteadyFairShare = (float)steadyFairResources.GetMemory() / clusterResources .GetMemory(); fractionMemFairShare = (float)fairResources.GetMemory() / clusterResources.GetMemory (); fractionMemMinShare = (float)minResources.GetMemory() / clusterResources.GetMemory (); fractionMemMaxShare = (float)maxResources.GetMemory() / clusterResources.GetMemory (); maxApps = allocConf.GetQueueMaxApps(queueName); childQueues = new AList <Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Webapp.Dao.FairSchedulerQueueInfo >(); if (allocConf.IsReservable(queueName) && !allocConf.GetShowReservationAsQueues(queueName )) { return; } ICollection <FSQueue> children = queue.GetChildQueues(); foreach (FSQueue child in children) { if (child is FSLeafQueue) { childQueues.AddItem(new FairSchedulerLeafQueueInfo((FSLeafQueue)child, scheduler) ); } else { childQueues.AddItem(new Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Webapp.Dao.FairSchedulerQueueInfo (child, scheduler)); } } }
/// <exception cref="System.IO.IOException"/> public virtual void SelectInputStreams(ICollection <EditLogInputStream> streams, long fromTxId, bool inProgressOk) { IList <EditLogLedgerMetadata> currentLedgerList = GetLedgerList(fromTxId, inProgressOk ); try { BookKeeperEditLogInputStream elis = null; foreach (EditLogLedgerMetadata l in currentLedgerList) { long lastTxId = l.GetLastTxId(); if (l.IsInProgress()) { lastTxId = RecoverLastTxId(l, false); } // Check once again, required in case of InProgress and is case of any // gap. if (fromTxId >= l.GetFirstTxId() && fromTxId <= lastTxId) { LedgerHandle h; if (l.IsInProgress()) { // we don't want to fence the current journal h = bkc.OpenLedgerNoRecovery(l.GetLedgerId(), BookKeeper.DigestType.Mac, Sharpen.Runtime.GetBytesForString (digestpw, Charsets.Utf8)); } else { h = bkc.OpenLedger(l.GetLedgerId(), BookKeeper.DigestType.Mac, Sharpen.Runtime.GetBytesForString (digestpw, Charsets.Utf8)); } elis = new BookKeeperEditLogInputStream(h, l); elis.SkipTo(fromTxId); } else { // If mismatches then there might be some gap, so we should not check // further. return; } streams.AddItem(elis); if (elis.GetLastTxId() == HdfsConstants.InvalidTxid) { return; } fromTxId = elis.GetLastTxId() + 1; } } catch (BKException e) { throw new IOException("Could not open ledger for " + fromTxId, e); } catch (Exception ie) { Sharpen.Thread.CurrentThread().Interrupt(); throw new IOException("Interrupted opening ledger for " + fromTxId, ie); } }
internal virtual void AddChild(Org.Apache.Hadoop.Mapred.Queue child) { if (children == null) { children = new TreeSet <Org.Apache.Hadoop.Mapred.Queue>(); } children.AddItem(child); }
/// <summary> /// Adds an arbitrary String label to this /// <see cref="TextBlock">TextBlock</see> /// . /// </summary> /// <param name="label">The label</param> /// <seealso cref="NBoilerpipe.Labels.DefaultLabels">NBoilerpipe.Labels.DefaultLabels /// </seealso> public virtual void AddLabel(string label) { if (labels == null) { labels = new HashSet <string>(); } labels.AddItem(label); }
/// <summary> /// Called by /// <see cref="TestingThread"/> /// s to signal /// a successful completion. /// </summary> /// <param name="t">the thread that finished.</param> public virtual void ThreadDone(MultithreadedTestUtil.TestingThread t) { lock (this) { finishedThreads.AddItem(t); Runtime.Notify(this); } }
public virtual void RegisterLaunchedTask(TaskAttemptId attemptID, WrappedJvmID jvmId ) { // The AM considers the task to be launched (Has asked the NM to launch it) // The JVM will only be given a task after this registartion. launchedJVMs.AddItem(jvmId); taskHeartbeatHandler.Register(attemptID); }
/// <exception cref="System.IO.IOException"/> public override void Close() { if (closedSet != null) { closedSet.AddItem(this); } base.Close(); }
/// <summary>Find the set of lanes passing through a commit's row.</summary> /// <remarks> /// Find the set of lanes passing through a commit's row. /// <p> /// Lanes passing through a commit are lanes that the commit is not directly /// on, but that need to travel through this commit to connect a descendant /// (child) commit to an ancestor (parent) commit. Typically these lanes will /// be drawn as lines in the passed commit's box, and the passed commit won't /// appear to be connected to those lines. /// <p> /// This method modifies the passed collection by adding the lanes in any /// order. /// </remarks> /// <param name="currCommit">the commit the caller needs to get the lanes from.</param> /// <param name="result">collection to add the passing lanes into.</param> public virtual void FindPassingThrough(PlotCommit <L> currCommit, ICollection <L> result ) { foreach (PlotLane p in currCommit.passingLanes) { result.AddItem((L)p); } }
private CSAssignment AssignContainersToChildQueues(Org.Apache.Hadoop.Yarn.Api.Records.Resource cluster, FiCaSchedulerNode node, ResourceLimits limits) { lock (this) { CSAssignment assignment = new CSAssignment(Resources.CreateResource(0, 0), NodeType .NodeLocal); PrintChildQueues(); // Try to assign to most 'under-served' sub-queue for (IEnumerator <CSQueue> iter = childQueues.GetEnumerator(); iter.HasNext();) { CSQueue childQueue = iter.Next(); if (Log.IsDebugEnabled()) { Log.Debug("Trying to assign to queue: " + childQueue.GetQueuePath() + " stats: " + childQueue); } // Get ResourceLimits of child queue before assign containers ResourceLimits childLimits = GetResourceLimitsOfChild(childQueue, cluster, limits ); assignment = childQueue.AssignContainers(cluster, node, childLimits); if (Log.IsDebugEnabled()) { Log.Debug("Assigned to queue: " + childQueue.GetQueuePath() + " stats: " + childQueue + " --> " + assignment.GetResource() + ", " + assignment.GetType()); } // If we do assign, remove the queue and re-insert in-order to re-sort if (Resources.GreaterThan(resourceCalculator, cluster, assignment.GetResource(), Resources.None())) { // Remove and re-insert to sort iter.Remove(); Log.Info("Re-sorting assigned queue: " + childQueue.GetQueuePath() + " stats: " + childQueue); childQueues.AddItem(childQueue); if (Log.IsDebugEnabled()) { PrintChildQueues(); } break; } } return(assignment); } }
public override void ReleaseAssignedContainer(ContainerId containerId) { lock (this) { Preconditions.CheckArgument(containerId != null, "ContainerId can not be null."); pendingRelease.AddItem(containerId); release.AddItem(containerId); } }
/// <param name="file">the file to add</param> /// <returns>this instance</returns> public virtual NGit.Api.ResetCommand AddPath(string file) { if (mode != null) { throw new JGitInternalException(MessageFormat.Format(JGitText.Get().illegalCombinationOfArguments , "<paths>...", "[--mixed | --soft | --hard]")); } filepaths.AddItem(file); return(this); }
/// <exception cref="NGit.Errors.TransportException"></exception> private void ExpandWildcard(RefSpec spec, ICollection <Ref> matched) { foreach (Ref src in conn.GetRefs()) { if (spec.MatchSource(src) && matched.AddItem(src)) { Want(src, spec.ExpandFromSource(src)); } } }
public DocumentTitleMatchClassifier(string title) { if (title == null) { this.potentialTitles = null; } else { title = title.Trim(); if (title.Length == 0) { this.potentialTitles = null; } else { this.potentialTitles = new HashSet<string>(); potentialTitles.AddItem(title); string p; p = GetLongestPart(title, "[ ]*[\\|»|:][ ]*"); if (p != null) { potentialTitles.AddItem(p); } p = GetLongestPart(title, "[ ]*[\\|»|:\\(\\)][ ]*"); if (p != null) { potentialTitles.AddItem(p); } p = GetLongestPart(title, "[ ]*[\\|»|:\\(\\)\\-][ ]*"); if (p != null) { potentialTitles.AddItem(p); } p = GetLongestPart(title, "[ ]*[\\|»|,|:\\(\\)\\-][ ]*"); if (p != null) { potentialTitles.AddItem(p); } } } }
/// <exception cref="NGit.Errors.TransportException"></exception> private void ExpandSingle(RefSpec spec, ICollection<Ref> matched) { Ref src = conn.GetRef(spec.GetSource()); if (src == null) { throw new TransportException(MessageFormat.Format(JGitText.Get().remoteDoesNotHaveSpec , spec.GetSource())); } if (matched.AddItem(src)) { Want(src, spec); } }
private String GetDesignDocFunction(String fnName, String key, ICollection<String> outLanguageList) { var path = fnName.Split('/'); if (path.Length != 2) { return null; } var docId = string.Format("_design/{0}", path[0]); var rev = GetDocumentWithIDAndRev(docId, null, DocumentContentOptions.None); if (rev == null) { return null; } var outLanguage = (string)rev.GetPropertyForKey("language"); if (outLanguage != null) { outLanguageList.AddItem(outLanguage); } else { outLanguageList.AddItem("javascript"); } var container = (IDictionary<String, Object>)rev.GetPropertyForKey(key); return (string)container.Get(path[1]); }
/// <exception cref="System.IO.IOException"></exception> private void Service() { if (biDirectionalPipe) { SendAdvertisedRefs(new RefAdvertiser.PacketLineOutRefAdvertiser(pckOut)); } else { if (requestPolicy == UploadPack.RequestPolicy.ANY) { advertised = Sharpen.Collections.EmptySet<ObjectId>(); } else { advertised = new HashSet<ObjectId>(); foreach (Ref @ref in GetAdvertisedOrDefaultRefs().Values) { if (@ref.GetObjectId() != null) { advertised.AddItem(@ref.GetObjectId()); } } } } bool sendPack; try { RecvWants(); if (wantIds.IsEmpty()) { preUploadHook.OnBeginNegotiateRound(this, wantIds, 0); preUploadHook.OnEndNegotiateRound(this, wantIds, 0, 0, false); return; } if (options.Contains(OPTION_MULTI_ACK_DETAILED)) { multiAck = BasePackFetchConnection.MultiAck.DETAILED; noDone = options.Contains(OPTION_NO_DONE); } else { if (options.Contains(OPTION_MULTI_ACK)) { multiAck = BasePackFetchConnection.MultiAck.CONTINUE; } else { multiAck = BasePackFetchConnection.MultiAck.OFF; } } if (depth != 0) { ProcessShallow(); } sendPack = Negotiate(); } catch (PackProtocolException err) { ReportErrorDuringNegotiate(err.Message); throw; } catch (ServiceMayNotContinueException err) { if (!err.IsOutput() && err.Message != null) { try { pckOut.WriteString("ERR " + err.Message + "\n"); err.SetOutput(); } catch { } } // Ignore this secondary failure (and not mark output). throw; } catch (IOException err) { ReportErrorDuringNegotiate(JGitText.Get().internalServerError); throw; } catch (RuntimeException err) { ReportErrorDuringNegotiate(JGitText.Get().internalServerError); throw; } catch (Error err) { ReportErrorDuringNegotiate(JGitText.Get().internalServerError); throw; } if (sendPack) { SendPack(); } }
/// <exception cref="System.IO.IOException"></exception> private void Service() { if (biDirectionalPipe) { SendAdvertisedRefs(new RefAdvertiser.PacketLineOutRefAdvertiser(pckOut)); } else { advertised = new HashSet<ObjectId>(); foreach (Ref @ref in GetAdvertisedRefs().Values) { if (@ref.GetObjectId() != null) { advertised.AddItem(@ref.GetObjectId()); } } } RecvWants(); if (wantIds.IsEmpty()) { preUploadHook.OnBeginNegotiateRound(this, wantIds, 0); preUploadHook.OnEndNegotiateRound(this, wantIds, 0, 0, false); return; } if (options.Contains(OPTION_MULTI_ACK_DETAILED)) { multiAck = BasePackFetchConnection.MultiAck.DETAILED; noDone = options.Contains(OPTION_NO_DONE); } else { if (options.Contains(OPTION_MULTI_ACK)) { multiAck = BasePackFetchConnection.MultiAck.CONTINUE; } else { multiAck = BasePackFetchConnection.MultiAck.OFF; } } if (Negotiate()) { SendPack(); } }
static AmazonS3() { SIGNED_HEADERS = new HashSet<string>(); SIGNED_HEADERS.AddItem("content-type"); SIGNED_HEADERS.AddItem("content-md5"); SIGNED_HEADERS.AddItem("date"); }
/// <exception cref="System.IO.IOException"></exception> public override void Resolve(ICollection<ObjectId> matches, AbbreviatedObjectId id , int matchLimit) { int[] data = names[id.FirstByte]; int max = (int)(((uint)offset32[id.FirstByte].Length) >> 2); int high = max; if (high == 0) { return; } int low = 0; do { int p = (int)(((uint)(low + high)) >> 1); int cmp = id.PrefixCompare(data, IdOffset(p)); if (cmp < 0) { high = p; } else { if (cmp == 0) { // We may have landed in the middle of the matches. Move // backwards to the start of matches, then walk forwards. // while (0 < p && id.PrefixCompare(data, IdOffset(p - 1)) == 0) { p--; } for (; p < max && id.PrefixCompare(data, IdOffset(p)) == 0; p++) { matches.AddItem(ObjectId.FromRaw(data, IdOffset(p))); if (matches.Count > matchLimit) { break; } } return; } else { low = p + 1; } } } while (low < high); }
/// <exception cref="NGit.Errors.TransportException"></exception> private void ExpandWildcard(RefSpec spec, ICollection<Ref> matched) { foreach (Ref src in conn.GetRefs()) { if (spec.MatchSource(src) && matched.AddItem(src)) { Want(src, spec.ExpandFromSource(src)); } } }
/// <exception cref="System.IO.IOException"></exception> internal override void Resolve(ICollection<ObjectId> matches, AbbreviatedObjectId id) { // Go through the packs once. If we didn't find any resolutions // scan for new packs and check once more. // int oldSize = matches.Count; ObjectDirectory.PackList pList = packList.Get(); for (; ; ) { foreach (PackFile p in pList.packs) { try { p.Resolve(matches, id, RESOLVE_ABBREV_LIMIT); } catch (IOException) { // Assume the pack is corrupted. // RemovePack(p); } if (matches.Count > RESOLVE_ABBREV_LIMIT) { return; } } if (matches.Count == oldSize) { ObjectDirectory.PackList nList = ScanPacks(pList); if (nList == pList || nList.packs.Length == 0) { break; } pList = nList; continue; } break; } string fanOut = Sharpen.Runtime.Substring(id.Name, 0, 2); string[] entries = new FilePath(GetDirectory(), fanOut).List(); if (entries != null) { foreach (string e in entries) { if (e.Length != Constants.OBJECT_ID_STRING_LENGTH - 2) { continue; } try { ObjectId entId = ObjectId.FromString(fanOut + e); if (id.PrefixCompare(entId) == 0) { matches.AddItem(entId); } } catch (ArgumentException) { continue; } if (matches.Count > RESOLVE_ABBREV_LIMIT) { return; } } } foreach (FileObjectDatabase.AlternateHandle alt in MyAlternates()) { alt.db.Resolve(matches, id); if (matches.Count > RESOLVE_ABBREV_LIMIT) { return; } } }
static Database() { // Default value for maxRevTreeDepth, the max rev depth to preserve in a prune operation KnownSpecialKeys = new HashSet<string>(); KnownSpecialKeys.AddItem("_id"); KnownSpecialKeys.AddItem("_rev"); KnownSpecialKeys.AddItem("_attachments"); KnownSpecialKeys.AddItem("_deleted"); KnownSpecialKeys.AddItem("_revisions"); KnownSpecialKeys.AddItem("_revs_info"); KnownSpecialKeys.AddItem("_conflicts"); KnownSpecialKeys.AddItem("_deleted_conflicts"); }
/// <exception cref="System.IO.IOException"></exception> private void Service() { if (biDirectionalPipe) { SendAdvertisedRefs(new RefAdvertiser.PacketLineOutRefAdvertiser(pckOut)); } else { advertised = new HashSet<ObjectId>(); refs = refFilter.Filter(db.GetAllRefs()); foreach (Ref @ref in refs.Values) { if (@ref.GetObjectId() != null) { advertised.AddItem(@ref.GetObjectId()); } } } RecvWants(); if (wantAll.IsEmpty()) { return; } if (options.Contains(OPTION_MULTI_ACK_DETAILED)) { multiAck = BasePackFetchConnection.MultiAck.DETAILED; } else { if (options.Contains(OPTION_MULTI_ACK)) { multiAck = BasePackFetchConnection.MultiAck.CONTINUE; } else { multiAck = BasePackFetchConnection.MultiAck.OFF; } } if (Negotiate()) { SendPack(); } }