您如何指示SharePoint场在特定服务器上运行计时器作业? [英] How do you instruct a SharePoint Farm to run a Timer Job on a specific server?

查看:104
本文介绍了您如何指示SharePoint场在特定服务器上运行计时器作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个SP计时器作业,运行了好一阵子.最近,管理员邀请另一台服务器加入服务器场,因此SharePoint决定开始在另一台服务器上运行此计时器作业.问题是服务器上没有安装所有依赖项(即Oracle),因此作业失败.我只是在这里寻找阻力最小的路径.我的问题是有一种方法可以强制计时器作业在您想要的服务器上运行吗?

We have an SP timer job that was running fine for quite a while. Recently the admins enlisted another server into the farm, and consequently SharePoint decided to start running this timer job on this other server. The problem is the server does not have all the dependencies installed (i.e., Oracle) on it and so the job is failing. I'm just looking for the path of least resistance here. My question is there a way to force a timer job to run on the server you want it to?

如果我可以通过对我有用的代码来做到这一点.如果确实存在,我只需要知道API会执行的操作.

If I can do it through code that works for me. I just need to know what the API is to do this if one does exist.

推荐答案

如果我为显而易见的事情努力,我深表歉意.我只是还没有看到任何人对此进行深入研究.

I apologize if I'm pushing for the obvious; I just haven't seen anyone drill down on it yet.

通过控制构造函数参数来约束自定义计时器作业(即,您自己的从SPJobDefinition派生的计时器作业类).

Constraining a custom timer job (that is, your own timer job class that derives from SPJobDefinition) is done by controlling constructor parameters.

计时器作业通常在提交作业的服务器上运行(如vinny所示),前提是在创建计时器作业期间未指定目标服务器.但是,两个重载的SPJobDefinition类型的构造函数分别接受SPServer和SPJobLockType作为第三个参数和第四个参数.正确使用这两个参数将使您能够确定作业的运行位置.

Timer jobs typically run on the server where they are submitted (as indicated by vinny) assuming no target server is specified during the creation of the timer job. The two overloaded constructors for the SPJobDefinition type, though, accept an SPServer and an SPJobLockType as the third and fourth parameters, respectively. Using these two parameters properly will allow you to dictate where your job runs.

通过将目标服务器指定为SPServer,并将SPJobLockType指定为"Job",可以约束您创建的计时器作业实例在您选择的服务器上运行.

By specifying your target server as the SPServer and an SPJobLockType of "Job," you can constrain the timer job instance you create to run on the server of your choice.

有关我所描述内容的文档,请参见MSDN: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spjobdefinition.spjobdefinition.aspx .

For documentation on what I've described, see MSDN: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spjobdefinition.spjobdefinition.aspx.

我对您正在运行的代码一无所知,但是自定义计时器作业通常是在功能激活期间设置的.我感觉到您的代码库可能不是您自己的(?);如果是这样,则可能要查找从SPFeatureReceiver派生的一个或多个类型/类.在此类的FeatureActivated方法中,您可能会找到实际执行计时器作业实例化的代码.

I don't know anything about the code you're running, but custom timer jobs are commonly setup during Feature activation. I got the sense that your codebase might not be your own (?); if so, you might want to look for the one or more types/classes that derive from SPFeatureReceiver. In the FeatureActivated method of such classes is where you might find the code that actually carries out the timer job instantiation.

当然,您还需要查看自定义计时器作业类(或多个类)本身,以了解如何实例化它们.有时,开发人员会将类的实例化构建到类本身中(例如,通过Factory Method模式).不过,在计时器作业类和SPFeatureReceiver实现之间,您应该正在寻找需要更改的地方.

Of course, you'll also want to look at the custom timer job class (or classes) themselves to see how they're being instantiated. Sometimes developers will build the instantiation of the class into the class itself (via Factory Method pattern, for example). Between the timer job class and SPFeatureReceiver implementations, though, you should be on the way towards finding what needs to change.

希望对您有帮助!

这篇关于您如何指示SharePoint场在特定服务器上运行计时器作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆