SharePoint Timer Job Locks and Scope - gsraju91



SharePoint Interview Questions and Answers: MasterPageWhat is master page and use of it?Types of master pages in SharePoint?Is any improvements in SharePoint 2010 masterpage when compared to SharePoint 2007?Difference between master pages and SharePoint master pages?How to set our custom master page as default master page programmatically?How to configure user controls(.ascx) in master pages?How to add webparts to the master pages?Can I use .Net master pages into SharePoint directly?How to configure the images, css, style sheets in master pages?What is delegate control and use of it in SharePoint master pages?What are all types of delegate controls in master pages?What all are contentplaceholders in master pages?I have developed one custom master page and I want to set my custom master page as default master for every newly site collections, site, web etc.?Difference between SharePoint foundation master pages and SharePoint server master pages?How to set the custom master as default master to the site in both SharePoint foundation 2010 and SharePoint server2010?How to set the same masterpage to the child sites in both SharePoint foundation 2010 and SharePoint server2010?How to hide the “Home” tab(means first node on topNavBar) in master page 2010?Difference between deploying masterpage using farm solution and sandbox solution?Can we deploy published site master page into SharePoint foundation sites?Masterpage and page layouts options missing in the left navigation in SharePoint designer2010?Event receivers with custom application pages in SharePoint 2010?What’s the difference between MasterPageFile and DynamicMasterPageFile?What is the difference between deploying custom master pages either using sandbox and farm solution???? HYPERLINK "" What is master page and use of it?Masterpage provides layouts for set of pages. Master Pages are a template that other pages can inherit from to keep consistent functionality. The pages that inherit from Master Pages are referred to as content pages.In SharePoint, when we add a new page from browser by going to Site Actions and select Create Page then there we will select the page layout and create the page. So we are selecting the page layout, it’s always binds to a master page. Whenever you change the default or custom master page, then the changes will be applied to all the page layouts by default. Because SharePoint won’t give direct master page URL or name anywhere. It will be ~masterurl/custom.master for custom master page and ~masterurl/default.master for the default master page.Only one gallery exists per site collection and it is automatically populated when a new site collection is provisioned. Master pages cannot be shared across site collections, but a root site can share its master pages with the other sites in its site collection.Ref:?: Master Page directive at the top of the page:?<%@Master language=”C#”%> HYPERLINK "" What are Content Pages?Content pages are the pages that implement a Master Page. Content pages are normal pages that contain an attribute which informs the compiler that the page should be merged with a Master Page. This attribute is part of the page directive tag and is called the?MasterPageFileWhat all are content placeholders in master pages?Master page in SharePoint contains Content PlaceHolders. Content placeholders are areas of replaceable content on the master page. The tag is <asp:ContentPlaceHolder>. A master page may define many ContentPlaceHolder controls; a page does not have to implement a corresponding content control. There are contentplaceholders like PlaceHolderMain, which displays the main body of the page. PlaceHolderLeftNavBar, which contains the Quick Launch bar on the left side of the page, PlaceHolderTopNavBar, which contains the Top Navigation tabs at the top of the page, and PlaceHolderSearchArea, which contains the page’s search controls. HYPERLINK "" Total number of Content place holder in default master page?Total count: 33?Visual reference to above mentioned Content Place Holders are?? to properly hide Content Placeholders in your SharePoint Masterpage?Move the place holders which are not to show in asp panel and set the attribute visible to false. HYPERLINK "" What is Master Page Gallery?SharePoint master pages have their own list/library called the Master Page Gallery .To access a SharePoint master page gallery goes to a SharePoint?site collection??site settings???master page gallery. HYPERLINK "" Type of Master Pages in SharePointThere are 3 main types of Master Pages in SharePointSite Master PagesSystem Master PagesApplication Master PagesSite Master Pages?are usually used in SharePoint publishing site definitions. These pages are used for the main .This is needed for publishing pages because the main page, of a site or sub site, usually has the publishing feature turned.Site master pages are defined by?~masterurl/custom.master?in the content page declaration.System master pages?are used for most non-publishing sites and subpages (list or library) in publishing sites.?System master pages are defined by?~masterurl/default.master?in the content page declaration.Application master pages?are for all “Layout” pages. Layout pages are SharePoint administrative pages.??SharePoint interview Questions and anwers: Masterpage1 HYPERLINK "" Which are default master pages in SharePoint 2010?v4.master - This is default master pageDefault. Master - this is used to support the 2007 user interfaceMinimal. MasterSimple. Master- it is used for accessdenied.aspx, confirmation.aspx, error.aspx, login.aspx, reqacc.aspx, signout.aspx & webdeleted.aspx pagesV4.master:??Default master page for most non-publishing sites in SharePoint 2010. It is also the default system master page in both SharePoint Foundation and SharePoint Server.Default.master:?Helpful from upgrading MOSS 2007 sites to SharePoint 2010 sites.Minimal.master:?page is best suited for pages with minimal branding and navigation. The minimal.master is used with search pages and Office web applications.Simple.master:?Master page used for error and login pages. It lives in the fi le system and is not available in the master page gallery.MWSDefaultv4.master:?Found in the master page gallery of meeting workspace sites.Nightandday.master:?page contains controls specialized for publishing web content management. HYPERLINK "" Difference between Default.master and v4.master?V4.master: Default team site master page. Provides ribbon bar and other UI changes.Characteristics:Site actions are updated for 2010 and appear on left.Ribbon bar is availableDefault.master:?Sites upgraded from SharePoint 2007 use this unless they are changed to use a v4 version.Characteristics:Site actions on right side and are same as SharePoint 2007 versionNo ribbon bar HYPERLINK "" What is Page Layout??Page layout dictates the overall look and feel of a web page. A page layout relies on a content type to determine the kind of content that can be stored on pages. Page layout contains field controls and web part. HYPERLINK "" What is the Difference between Master Pages and Layout Pages in SharePoint?Master pages and page layouts dictate the overall look and feel of your SharePoint site.Differences areMaster pages contain controls that are shared across multiple page layouts, such as navigation, search, or language-preference for multilingual sites. Page layouts contain field controls and Web PartsPage layouts can be used by all page instances that are based on that page layout. Master pages can be used by all page instances in a site. HYPERLINK "" What is Navigation in SharePoint 2010?Site navigation provides the primary interface for site users to move around on the sites and pages on the site.? HYPERLINK "" What are the various options for Navigation available in SharePoint 2010?Navigation controls on master pagesTop link bar navigationQuick Launch navigationBreadcrumb navigationTree view navigationMetadata navigationNavigation controls on page layoutsSummary LinksTable of ContentsContent QueryNavigation Web PartsCategoriesSite AggregatorSite in CategoryTag Cloud HYPERLINK "" What is Ribbon interface?Ribbon Interface act as the UI enhancement in the product. It provides the commands to be executed in the form of Icons and tabs. HYPERLINK "" How to set our custom master page as default master page programmatically or how can we deploy custom master page using visual studio?Select Empty Sharepoint template as a project template and select the module item for master page and css.<Module Name="CustomMaster" Url="_catalogs/masterpage">??<File Path="CustomMaster\custommaster.master" Url="custommaster.master" Type="GhostableInLibrary" />"Url="_catalogs/masterpage"" means this will be deployed to the master page library in SharePoint.<Module Name="CustomCSS" Url="Style Library"><File Path="CustomCSS\DAVCSS.css"??Url="CustomCSS/yourfile.css"?Type="GhostableInLibrary" />"Url="Style Library"" means this will be deployed to the style library in SharePoint.Now add the following code in the feature receiver class file that contains above modules. Right click on the feature and click "Add Event Receiver"public override void featureactivated(spfeaturereceiverproperties properties)??{??????spsite currsite = (spsite)properties.feature.parent;??????spweb curweb = currsite.rootweb;?????uri masteruri = new uri(curweb.url + "/_catalogs/masterpage/custommaster.master");?????curweb.masterurl = masteruri.absolutepath;?????curweb.custommasterurl = masteruri.absolutepath;curweb.update();???}???This will apply the master page on activation of the feature.??public override void featuredeactivating(spfeaturereceiverproperties properties)??{?????????spsite currsite = (spsite)properties.feature.parent;????????spweb curweb = currsite.rootweb;???????uri masteruri = new uri(curweb.url + "/_catalogs/masterpage/v4.master");???????curweb.masterurl?= masteruri.absolutepath;??????curweb.custommasterurl = masteruri.absolutepath;???????curweb.update();????}Ref:? HYPERLINK "" How to add user controls (.ascx) in master pages/SharePoint pages/web part?3 steps involved to add the user controlCreate and deploy user controlRegister user control in the target<%@ Register TagPrefix="MyUserControl"??TagName="UserName" Src="~/_controltemplates/MyUserControl/MyUserControl.ascx" %>Insert the user control wherever required.<MyUserControl:UserName id="MyUserControl1" runat="server" />Note: For webpart (Page.LoadControl method) HYPERLINK "" How to add web parts to the master pages?Use SharePoint designer. Register the namespace of the web part class using <% Register directive. Then use the specified tag prefix from "Register" directive to add the instance of Web part class. Web parts outside the web part zones are referred as?static web parts?and behave as normal web control. HYPERLINK "" How to configure the images, css, style sheets in master pages?Register the custom css file as below .<SharePoint:CssRegistration name="<% $SPUrl:~SiteCollection/Style Library/Custom/styles.css %>" After="corev4.css" runat="server"/>In CSS, we can wirtie the style for attaching image?background:url(../images/mainBG.jpg) HYPERLINK "" Delegate Control and usage of itWith the help of delegate control, we can take any OOB control of SharePoint and replace with our custom control without any modification in the SharePoint page. So that new custom control overrides the existing one.So the delegate control provide one of the option to add control (either server control or user control) on a SharePoint pageFor example : In master page SearchBox control is included as??<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" />This delegate control object uses features to locate the control which is specified in?ControlId.We can overwrite the above delegate control by presenting the below code in Element file of feature??<Control Id = "GlobalNavigation" Sequence="90"?ControlSrc="~/_ControlTemplates/ucGlobNavDelegateControl.ascx" /> HYPERLINK "" Delegate Controls in default master pageAdditionalPageHead,??GlobalSiteLink(), GlobalSiteLink1, GlobalSiteLink2, SmallSearcgInputBox,TopNavigationDataSource, PublicConsole, QuickLaunchDatasource HYPERLINK "" New Delegate controls in SharePoint 2013 master page:Searching through the main master page, Seattle.master, I’ve found these three new DelegateControls:PromotedActionsSuiteBarBrandingDelegateSuiteLinksDelegateRefer:?? HYPERLINK "" I have developed one custom master page and I want to set my custom master page as default master for every newly site collections, site, web etc.???or Set custom Master page as default for all newly created sitesYou can enable a Web Provisioned event receiverusing (SPWeb childSite = properties.Web)?{???using (SPWeb topSite = childSite.Site.RootWeb)??{????childSite.MasterUrl = topSite.MasterUrl;???????childSite.CustomMasterUrl = topSite.CustomMasterUrl;??????childSite.Update();???}?} HYPERLINK "" Four Ways to Add or Remove the Quick Launch Menu ControlUsing the SharePoint web interface or SharePoint Designer 2010Using a master pageUsing a page layoutUsing a Content Editor Web Part HYPERLINK "" Applying custom master to “my site”This has to be done in the site definition file system. I don't think there is an Interface for that, but it can be via SPD though. HYPERLINK "" What is the Master Page Gallery library template ID?List Attribute Id= 116 HYPERLINK "" How to hide the “Home” tab(means first node on topNavBar) in master page 2010?Changes in topnavigation control in??master page.Ref:? page and page layouts options missing in the left navigation in SharePoint designer2010Users having site ownership privileges are able to view the site's Collection Administration pages but will not see the link enabling them to make the appropriate settings change.Site collection administrators will enable the “Enable SharePoint Designer?“(Site Actions?SiteSettings?select SharePoint designer settings under site collection Administration category) HYPERLINK "" Use of SPSecurityTrimmedControl in master page?Conditionally renders the contents of the control to the current user only if the current user has permissions defined in the PermissionString.<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="XYZ"></Sharepoint:SPSecurityTrimmedControl>** Timer Job Locks and Scope** this post it's time we take our best shot at discussing a somewhat confusing topic - SharePoint timer job locks and scopes. I'll do my best to describe things; if you have questions or need further clarification post a comment and I'll attempt to clarify further.All timer jobs have a scope of action - an object type upon which they are intended to work. This scope may be the farm, an individual server, or a content database. That is, for each iteration of a job, it is expected to execute once per farm, once per server, or once per content database. These are reflected in the three values of the? HYPERLINK "" SPJobLockType?enum: Job, None, and ContentDatabase.?Job?means the job runs only once per farm per iteration;?None?means the job runs once per server; and?ContentDatabase?means the job runs once for each content database. The reason None is an appropriate description for a server-specific lock is that, as described in an earlier post, there is exactly one Timer Service Instance per server. When each timer service instance runs a job without checking or taking any locks, the result is that the job is run once per server. So "no lock" or None is the logical equivalent of a per-server lock.We'll now discuss some elements of each type of lock.Job Locks - Farm Scope (SPJobLockType.Job)Jobs which have a lock of type Job run once per farm (per iteration). Examples of this type of job include the Password Management job, CEIP data collection job, and the Delete Job History job. Jobs with this scope typically take an action effecting farm-wide settings and configuration and run only once (per iteration).To retrieve all farm-scoped jobs, run the following PowerShell command:Get-SPTimerJob | ? {$_.LockType -eq "Job"}To ensure only one server runs each job with a lock of scope Job (i.e. farm), locks are associated with a single specific server via a table in the Configuration Database (TimerLocks). Once taken by a server, the lock is typically held by the same server until the Timer Service on that server is stopped. Every 15 minutes (by default), the internal Lock Refresh job runs to refresh the job locks for this server. Every 60 minutes (by default) the internal Sweep job runs. This job attempts to get a lock for?at?most?one job?for which this server did not previously have a lock. By default, job locks time out after 20 minutes (which means that when all is functioning properly the Refresh job will ensure no lock ever times out). See?the previous article in this seriesfor more discussion on the internal timer jobs (Refresh and Sweep).No Locks - Server Scope (SPJobLockType.None)Jobs which have a lock of type None run once on each server in the farm. Because each server in the farm has one timer service instance, a job intended to run on every server does not need to take any locks - each server simply knows it can run the job without further concern.Examples of jobs scoped to servers (Lock Type None) are the Config Refresh job, Timer Recycle job, and the Timer Locks job. To retrieve all server-scoped jobs, run:Get-SPTimerJob | ? {$_.LockType -eq "None"}Content Database Locks and Scope (SPJobLockType.ContentDatabase)Last but far from least are jobs intended to run once per content database. Most of these jobs relate to processing of content and other front-end elements. Examples of Content Database jobs are the Expiration and Hold Processing jobs, the Immediate Alerts jobs, Audit Log Trimming job, and Recycle Bin cleanup job. These jobs are associated with a Web Application (or all Web Applications) and consequently run for each content database in the Web Application. To retrieve a sorted list of all the different types of content database jobs configured in a farm, run this command:Get-SPTimerJob | ? {$_.LockType -eq "ContentDatabase"} | Select-Object -Unique | Sort-Object Name | Format-Table NameAcquisition and maintenance of content database locks for a server is handled by the Timer Service Lock Management job (job-timer-locks). Locks are tracked by an entry in a table (TimerLock) in each content database associating the database with a single server in the farm. Note that content database locks are handled at the server and database level, not at the individual job level. That is, a server which acquires a lock for a given content database takes responsibility for executing?all?jobs for that database. No other server in the farm will execute any jobs for that database.Content database locks expire after 10 minutes, a value which cannot be changed. Other details on content database locks will be presented when the Timer Service Lock Management job and SPContentDatabaseJobDefinition are discussed.This completes the details on job locks and scopes.Antoher way:-Member nameDescriptionNoneProvides no locks. The timer job runs on every machine in the farm on which the parent service is provisioned, unless the job I associated with a specified server in which case it runs on only that server (and only if the parent service is provisioned on the server).ContentDatabaseLocks the content database. A timer job runs one time for each content database associated with the Web application.JobLocks the timer job so that it runs only on one machine in the farm.SharePoint Timer Job – SPJobLockTypeThere are 3?SPJobLockType ?available:1.???????SPJobLockType.None?-- if you set it none, the instance will run in all the available servers in the Farm (e.g. Application Server Timer Job)2.???????SPJobLockType.ContentDatabase?– this will cause 3 instances to be running in each of the Web-Frontends.3.???????SPJobLockType.Job?– this will cause only one instance of the job to run on any of the front-end servers. (Note: it is possible to see multiple instances listed in the Job Status .. but if you look at the time it was last run.. only one would have run lately)If you have to develop a job, you have to first decide on the type of lock you need for your job.E.g. If your job does something with the files in the Web-Frontend server you might want to use a ContentDatabase lock.. or if you have something that manipulates the data in a list.. you will have to use Job lock.Note: If you use other types of locks to manipulate the data in a list.. the multiple job instances will run simultaneously and cause Data Update conflict errors.Note: If for any reason you re-deploy your job.. either put the dll directly in GAC or deploysolution.. make sure you restart the 'Windows Sharepoint Services Timer' service. (OWSTIMER.EXE)Note: The account used by the Timer service should have access to the Content Database.Here are some sample code(s) of a custom timer job definition:[Guid("{62FF3B87-654E-41B8-B997-A1EA6720B127}")]class?MyTimerJob1?:?SPJobDefinition{????public?MyTimerJob1()??????? :?base()??? { }????public?MyTimerJob1(string?name,?SPService?service,?SPServer?server,????????SPJobLockType?lockType) :?base(name, service, server, lockType)??? { }????public?MyTimerJob1(string?name,?SPWebApplication?webApplication,SPServer?server,????????SPJobLockType?lockType) :?base(name, webApplication, server, lockType)??? { }????public override void?Execute(Guid?targetInstanceId)??? {????????//Execute Timer Job Tasks????}}Remember that the different server roles that we can find on a Sharepoint farm are:Database Server: the server that hosts the Microsoft SQL Server database for the farm. Since Sharepoint Foundation is not typically installed in this server, no jobs will run here.Web Front End Server: server where the?Microsoft SharePoint Foundation Web Application service?is running on.Application Server: Any other Sharepoint server.Here are a couple of examples on where the jobs will run depending on the parameters passed to the constructor://Job associated with a web app, no server in particular and none lock:// will run on all fron end servers.var jobRunningOnAllFrontEndServers = new MyTimerJob1("mytimerjob", SPWebApplication.Lookup(webAppURI), null, SPJobLockType.None);//Job associated with a web app, one front end server and job lock:// will run only in the frontEndServer1 server.var jobRunningOnAParticularFronEndServer = new MyTimerJob1("mytimerjob", SPWebApplication.Lookup(webAppURI), fronEndServer1, SPJobLockType.Job);//Job associated with a webApp, and an app server and lock type job: // it won't run on any server since the server specified is NOT running // the Web Application Servicevar jobRunningOnNoServer = new MyTimerJob1("mytimerjob", SPWebApplication.Lookup(webAppURI), appServer1, SPJobLockType.Job);//Job associated with the timer service, a particular app server and none lock:// will run on the appServer1 server only.var jobRunningOnAppServer = new MyTimerJob1("mytimerjob", SPFarm.Local.TimerService, appServer1, SPJobLockType.None); ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download