예제 #1
0
        /// <summary>
        /// An event handler called when the user removes a slice from nodes.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnRemoveFromNodes(object sender, EventArgs e)
        {
            // If there is no validated PlanetLab person account, show a message and return.
            if (-1 == CrawlerConfig.Static.PlanetLabPersonId)
            {
                MessageBox.Show(this, "You must set and validate a PlanetLab account in the settings page before configuring the PlanetLab slices.", "PlanetLab Account Not Configured", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // If there is no node selected, do nothing.
            if (this.listViewNodes.SelectedItems.Count == 0) return;

            // Get the node information.
            NodeInfo info = (NodeInfo)this.listViewNodes.SelectedItems[0].Tag;

            // Confirm the removal.
            if (MessageBox.Show(
                this,
                "You are removing the current slice from the PlanetLab node {0}. Do you want to continue?".FormatWith(info.NodeId),
                "Confirm Removing the Slice from Node",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                // Create an identifiers array.
                int[] ids = new int[] { info.NodeId };

                // Update the status.
                this.status.Send(
                    ApplicationStatus.StatusType.Busy,
                    "Showing {0} PlanetLab slices.".FormatWith(this.crawler.PlanetLab.LocalSlices.Count),
                    "Removing slice {0} from {1} PlanetLab node{2}...".FormatWith(slice.Id, ids.Length, ids.Length.PluralSuffix()),
                    Resources.GlobeLab_16,
                    Resources.GlobeClock_16);
                // Log.
                this.controlLogList.Add(this.config.Log.Add(
                    LogEventLevel.Verbose,
                    LogEventType.Information,
                    ControlSlice.logSource.FormatWith(this.slice.Id),
                    "Removing slice {0} from the PlanetLab node{1} {2}.",
                    new object[] { slice.Id, ids.Length.PluralSuffix(), ids }));

                // Create the request state.
                IdsRequestState requestState = new IdsRequestState(
                    null,
                    this.OnRemoveSliceFromNodesRequestResult,
                    this.OnRemoveSliceFromNodesRequestCanceled,
                    this.OnRemoveSliceFromNodesRequestException,
                    this.OnRemoveSliceFromNodesRequestFinished,
                    ids);

                // Begin an asynchronous PlanetLab request.
                this.BeginRequest(
                    this.requestRemoveSliceFromNodes,
                    this.crawler.PlanetLab.Username,
                    this.crawler.PlanetLab.Password,
                    new object[] { this.slice.Id.Value, ids },
                    requestState);
            }
        }
예제 #2
0
        /// <summary>
        /// An event handler called when adding the current slice to PlanetLab nodes.
        /// </summary>
        /// <param name="ids">The list of node IDs.</param>
        private void OnAddSliceToNodes(int[] ids)
        {
            // If the slice does not have an ID, show an error message and return.
            if (!slice.Id.HasValue)
            {
                MessageBox.Show(this, "The selected slice does not have an identifier.", "Add Slice to Nodes", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Update the status.
            this.status.Send(
                ApplicationStatus.StatusType.Busy,
                "Showing {0} PlanetLab slices.".FormatWith(this.crawler.PlanetLab.LocalSlices.Count),
                "Adding slice {0} to {1} PlanetLab node{2}...".FormatWith(slice.Id, ids.Length, ids.Length.PluralSuffix()),
                Resources.GlobeLab_16,
                Resources.GlobeClock_16);
            // Log.
            this.controlLogList.Add(this.config.Log.Add(
                LogEventLevel.Verbose,
                LogEventType.Information,
                ControlSlice.logSource.FormatWith(this.slice.Id),
                "Adding slice {0} to the PlanetLab node{1} {2}.",
                new object[] { slice.Id, ids.Length.PluralSuffix(), ids }));

            // Create the request state.
            IdsRequestState requestState = new IdsRequestState(
                null,
                this.OnAddSliceToNodesRequestResult,
                this.OnAddSliceToNodesRequestCanceled,
                this.OnAddSliceToNodesRequestException,
                this.OnAddSliceToNodesRequestFinished,
                ids);

            // Begin an asynchronous PlanetLab request.
            this.BeginRequest(
                this.requestAddSliceToNodes,
                this.crawler.PlanetLab.Username,
                this.crawler.PlanetLab.Password,
                new object[] { slice.Id.Value, ids },
                requestState);
        }
예제 #3
0
        /// <summary>
        /// An event handler called when the list of sites is refreshed.
        /// </summary>
        private void OnRefreshSites()
        {
            lock (this.pendingSync)
            {
                // If there are no sites to refresh, do nothing.
                if (this.pendingSites.Count == 0) return;

                // Update the status.
                this.status.Send(
                    ApplicationStatus.StatusType.Busy,
                    @"Slice '{0}' has {1} node{2}.".FormatWith(this.slice.Name, this.slice.NodeIds.Length, this.slice.NodeIds.Length.PluralSuffix()),
                    "Refreshing the sites information...",
                    Resources.GlobeLab_16,
                    Resources.GlobeClock_16);
                // Log.
                this.controlLogList.Add(this.config.Log.Add(
                    LogEventLevel.Verbose,
                    LogEventType.Information,
                    ControlSlice.logSource.FormatWith(this.slice.Id),
                    "Refreshing the sites information."
                    ));

                // Create the request state.
                IdsRequestState requestState = new IdsRequestState(
                    null,
                    this.OnRefreshSitesRequestResult,
                    this.OnRefreshSitesRequestCanceled,
                    this.OnRefreshSitesRequestException,
                    null,
                    this.pendingSites.ToArray());

                // Begin an asynchronous PlanetLab request.
                this.BeginRequest(
                    this.requestGetSites,
                    this.crawler.PlanetLab.Username,
                    this.crawler.PlanetLab.Password,
                    PlSite.GetFilter(PlSite.Fields.SiteId, requestState.Ids),
                    requestState);

                // Clear the list of pending sites.
                this.pendingSites.Clear();
            }
        }