WWW.DISS.SELUK.RU

БЕСПЛАТНАЯ ЭЛЕКТРОННАЯ БИБЛИОТЕКА
(Авторефераты, диссертации, методички, учебные программы, монографии)

 

Pages:     | 1 | 2 || 4 | 5 |

«Содержание Введение 1 Системы мониторинга 1.1 Введение 1.2 Понятие систем мониторинга 1.3 Подсистемы мониторинга 1.3.1 Сбор данных 1.3.2 Хранение данных 1.3.3 Анализ данных 1.3.4 Отчетность 1.3.5 Оповещения 1.3.6 ...»

-- [ Страница 3 ] --

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.filter;

import com.googlecode.snoopyd.core.Kernel;

public abstract class AbstractKernelFilter implements KernelFilter { protected Kernel kernel;

public AbstractKernelFilter(Kernel kernel) { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.filter;

import com.googlecode.snoopyd.core.event.KernelEvent;

public interface KernelFilter { public static enum FilterAction {

ACCEPT, REJECT

public FilterAction accept(KernelEvent event);

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.filter;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.core.event.KernelEvent;

import com.googlecode.snoopyd.core.event.KernelStateChangedEvent;

public class ToogleFilter extends AbstractKernelFilter implements KernelFilter { public ToogleFilter(Kernel kernel) { public FilterAction accept(KernelEvent event) { FilterAction action = FilterAction.ACCEPT;

if (event instanceof KernelStateChangedEvent && kernel.peek() instanceof KernelStateChangedEvent) { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

import Ice.Identity;

public class ChildNodeDeadedEvent implements KernelEvent { private Ice.Identity identity;

public ChildNodeDeadedEvent(Identity identity) { public Ice.Identity identity() { public String name() { return this.getClass().getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

import Ice.Identity;

import com.googlecode.snoopyd.session.ISessionPrx;

public class ChildSessionRecivedEvent implements KernelEvent { private Ice.Identity identity;

private ISessionPrx session;

public ChildSessionRecivedEvent(Identity identity, ISessionPrx session) { public String name() { return this.getClass().getSimpleName();

public ISessionPrx session() { public Ice.Identity identity() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

import Ice.Identity;

import com.googlecode.snoopyd.session.ISessionPrx;

public class ChildSessionSendedEvent implements KernelEvent { private Identity identity;



private ISessionPrx session;

public ChildSessionSendedEvent(Identity identity, ISessionPrx session) { public String name() { return this.getClass().getSimpleName();

public ISessionPrx session() { public Ice.Identity identity() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

import java.util.Map;

public class DiscoverRecivedEvent implements KernelEvent { private Map context;

private Ice.Identity identity;

public DiscoverRecivedEvent(Ice.Identity identity, Map context) { public String name() { return this.getClass().getSimpleName();

public Map context() { public Ice.Identity identity() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

public class ExceptionEvent implements KernelEvent { private Throwable exception;

public ExceptionEvent(Throwable exception) { this.exception = exception;

public Throwable exception() { public String name() { return this.getClass().getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

public class ForceStartEvent implements KernelEvent { private String muid;

private String[] params;

public ForceStartEvent(String muid, String[] params) { public String muid() { public String[] params() { public String name() { return this.getClass().getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

public abstract class InvokationEvent implements KernelEvent, Runnable { public abstract void run();

public String name() { return InvokationEvent.class.getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

public interface KernelEvent { public String name();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

import java.util.Map;

public class KernelReconfiguredEvent implements KernelEvent { private Map configuration;

public KernelReconfiguredEvent(Map configuration) { this.configuration = configuration;

public Map configuration() { public String name() { return this.getClass().getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

import com.googlecode.snoopyd.core.state.KernelState;

public class KernelStateChangedEvent implements KernelEvent { private KernelState state;

public KernelStateChangedEvent(KernelState state) { public String name() { return this.getClass().getSimpleName();

public KernelState state() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

public class NetworkDisabledEvent implements KernelEvent { public String name() { return this.getClass().getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

public class NetworkEnabledEvent implements KernelEvent { public String name() { return this.getClass().getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

import Ice.Identity;

public class ParentNodeDeadedEvent implements KernelEvent { private Ice.Identity identity;

public ParentNodeDeadedEvent(Identity identity) { public Ice.Identity identity() { public String name() { return this.getClass().getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

import Ice.Identity;

import com.googlecode.snoopyd.session.IKernelSessionPrx;

public class ParentSessionRecivedEvent implements KernelEvent { private Ice.Identity identity;

private IKernelSessionPrx session;

public ParentSessionRecivedEvent(Identity identity, public String name() { return this.getClass().getSimpleName();

public Ice.Identity identity() { public IKernelSessionPrx sesssion() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

import com.googlecode.snoopyd.session.IKernelSessionPrx;

public class ParentSessionSendedEvent implements KernelEvent { private Ice.Identity identity;

private IKernelSessionPrx session;

public ParentSessionSendedEvent(Ice.Identity identity, IKernelSessionPrx session) { public String name() { return this.getClass().getSimpleName();

public IKernelSessionPrx session() { public Ice.Identity identity() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

import Ice.Identity;

public class ResultRecievedEvent implements KernelEvent { private Ice.Identity identity;

private String muid;

private String[] result;

public ResultRecievedEvent(Identity identity, String muid, String[] result) { public Ice.Identity identity() { public String muid() { public String[] result() { public String name() { return this.getClass().getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

public class ScheduleTimeComeEvent implements KernelEvent { private Ice.Identity identity;

private String muid;

private String[] params;

public ScheduleTimeComeEvent(Ice.Identity identity, String muid, String[] params) { public String name() { return this.getClass().getSimpleName();

public Ice.Identity identity() { public String muid() { public String[] params() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

import Ice.Identity;

public class ScheduleUpdatedEvent implements KernelEvent { public String name() { return this.getClass().getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

public class SnoopydStartedEvent implements KernelEvent { public String name() { return this.getClass().getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.core.event;

public class SnoopydTerminatedEvent implements KernelEvent { public String name() { return this.getClass().getSimpleName();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import com.googlecode.snoopyd.core.Kernel;

public abstract class AbstractDriver implements Driver { protected Kernel kernel;

protected String name;

public AbstractDriver(String name, Kernel kernel) { public Kernel kernel() { public String name() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

public interface Activable { public void activate();

public void deactivate();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import java.util.Map;

import org.apache.log4j.Logger;

import com.googlecode.snoopyd.Defaults;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.core.event.ChildNodeDeadedEvent;

import com.googlecode.snoopyd.core.event.ParentNodeDeadedEvent;

import com.googlecode.snoopyd.core.state.ActiveState;

import com.googlecode.snoopyd.core.state.KernelListener;

import com.googlecode.snoopyd.core.state.KernelState;

import com.googlecode.snoopyd.core.state.PassiveState;

import com.googlecode.snoopyd.session.IKernelSessionPrx;

import com.googlecode.snoopyd.session.ISessionPrx;

import com.googlecode.snoopyd.util.Identities;

public class Aliver extends AbstractDriver implements Driver, Runnable, private static Logger logger = Logger.getLogger(Aliver.class);

private boolean started;

public Aliver(Kernel kernel) { super(Aliver.class.getSimpleName(), kernel);

public void run() { } catch (InterruptedException ex) { @Override public synchronized void start() { logger.debug("starting " + name);

Thread self = new Thread(this, Defaults.ALIVER_THREAD_NAME);

@Override public synchronized void stop() { logger.debug("stoping " + name);

} catch (InterruptedException e) { logger.warn(e.getMessage());

@Override public synchronized void restart() { logger.debug("restarting " + name);

@Override public boolean started() { @Override public void stateChanged(KernelState currentState) { if (currentState instanceof ActiveState /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import java.util.HashMap;

import java.util.Map;

import java.util.Properties;

import org.apache.log4j.Logger;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.core.event.KernelReconfiguredEvent;

public class Configurer extends AbstractDriver implements Driver { private static Logger logger = Logger.getLogger(Configurer.class);

public Configurer(Kernel kernel) { super(Configurer.class.getSimpleName(), kernel);

public void reconfigure(Map configuration) { kernel.handle(new KernelReconfiguredEvent(configuration));

public Map configuration() { Properties prop = kernel.configuration();

prop.getProperty(key.toString()).toString());

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import org.apache.log4j.Logger;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.core.event.SnoopydTerminatedEvent;

public class Controller extends AbstractDriver implements Driver { private static Logger logger = Logger.getLogger(Controller.class);

public Controller(Kernel kernel) { super(Controller.class.getSimpleName(), kernel);

public void shutdown() { logger.debug("shutdown command received");

kernel.handle(new SnoopydTerminatedEvent());

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import java.util.HashMap;

import java.util.Map;

import org.apache.log4j.Logger;

import com.googlecode.snoopyd.Defaults;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.core.event.DiscoverRecivedEvent;

import com.googlecode.snoopyd.core.state.KernelListener;

import com.googlecode.snoopyd.core.state.KernelState;

import com.googlecode.snoopyd.core.state.OfflineState;

import com.googlecode.snoopyd.core.state.OnlineState;

import com.googlecode.snoopyd.core.state.SuspenseState;

import com.googlecode.snoopyd.util.Identities;

public class Discoverer extends AbstractDriver implements Driver, Runnable, private static Logger logger = Logger.getLogger(Discoverer.class);

private boolean started;

public Discoverer(Kernel kernel) { super(Discoverer.class.getSimpleName(), kernel);

public void discover(Ice.Identity identity, Map context) { StringBuilder sb = new StringBuilder();

Identities.toString(identity));

kernel.handle(new DiscoverRecivedEvent(identity, context));

public synchronized void start() { Thread self = new Thread(this, Defaults.DISCOVERER_THREAD_NAME);

public synchronized void stop() { public synchronized void restart() { logger.debug("restarting " + name);

public boolean started() { public void run() { com.googlecode.snoopyd.driver.IDiscovererPrxHelper.uncheckedCast(kernel.communicator().propertyToProxy( dmulticast = com.googlecode.snoopyd.driver.IDiscovererPrxHelper com.googlecode.snoopycp.core.IDiscovererPrxHelper.uncheckedCast(kernel.communicator().propertyToProxy( cpmulticast = com.googlecode.snoopycp.core.IDiscovererPrxHelper context.put("identity", Identities.toString(kernel.identity()));

context.put("primary", kernel.primaryPublishedEndpoints());

context.put("secondary", kernel.secondaryPublishedEndpoints());

context.put("state", kernel.state().getClass().getSimpleName());

} catch (InterruptedException ex) { public void stateChanged(KernelState currentState) { if (currentState instanceof OnlineState) { } else if (currentState instanceof OfflineState /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import com.googlecode.snoopyd.core.Kernel;

public interface Driver { public Kernel kernel();

public String name();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import java.util.HashMap;

import java.util.Map;

import org.apache.log4j.Logger;

import org.hyperic.sigar.Sigar;

import org.hyperic.sigar.SigarException;

import com.googlecode.snoopyd.core.Kernel;

public class Hoster extends AbstractDriver implements Driver { private static Logger logger = Logger.getLogger(Hoster.class);

private Sigar sigar;

public Hoster(Kernel kernel) { super(Hoster.class.getSimpleName(), kernel);

public Map context() { Map cpu = sigar.getCpuInfoList()[0].toMap();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import java.util.LinkedList;

import java.util.Map;

import java.util.Queue;

import org.apache.log4j.Logger;

import com.googlecode.snoopyd.Defaults;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.core.state.ActiveState;

import com.googlecode.snoopyd.core.state.KernelListener;

import com.googlecode.snoopyd.core.state.KernelState;

import com.googlecode.snoopyd.core.state.PassiveState;

* TODO: remove it public class Invoker extends AbstractDriver implements Driver, Runnable, private static Logger logger = Logger.getLogger(Invoker.class);

private boolean started;

public Invoker(Kernel kernel) { super(Invoker.class.getSimpleName(), kernel);

public synchronized void invoke(Map invokation) { public synchronized void start() { Thread self = new Thread(this, Defaults.INVOKER_THREAD_NAME);

self.start();

@Override public synchronized void stop() { logger.debug("stoping " + name);

started = false;

} catch (InterruptedException e) { logger.warn(e.getMessage());

@Override public synchronized void restart() { logger.debug("restarting " + name);

@Override public boolean started() { return started;

@Override public void run() { public void stateChanged(KernelState currentState) { if (currentState instanceof ActiveState /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import java.util.Map;

import org.apache.log4j.Logger;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.core.event.ForceStartEvent;

import com.googlecode.snoopymm.ModuleNotFoundException;

public class Moduler extends AbstractDriver implements Driver { private static Logger logger = Logger.getLogger(Moduler.class);

public Moduler(Kernel kernel) { super(Moduler.class.getSimpleName(), kernel);

public Map fetch() { return kernel.moduleManager().fetch();

com.googlecode.snoopyd.driver.ModuleNotFoundException { return kernel.moduleManager().launch(muid, params);

} catch (ModuleNotFoundException ex) { throw new com.googlecode.snoopyd.driver.ModuleNotFoundException();

public void deploy(String muid, String code) { kernel.moduleManager().deploy(muid, code);

public void undeploy(String muid) throws ModuleNotFoundException { kernel.moduleManager().undeploy(muid);

public void force(String muid, String[] params) { kernel.handle(new ForceStartEvent(muid, params));

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import java.net.NetworkInterface;

import java.net.SocketException;

import java.util.Enumeration;

import org.apache.log4j.Logger;

import com.googlecode.snoopyd.Defaults;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.core.event.NetworkDisabledEvent;

import com.googlecode.snoopyd.core.event.NetworkEnabledEvent;

public class Networker extends AbstractDriver implements Driver, Activable, private static Logger logger = Logger.getLogger(Networker.class);

public static final int NETWORK_UNDEFINED = -1;

public static final int NETWORK_ENABLED = 0;

public static final int NETWORK_DISABLED = 1;

private int networkState;

private boolean started;

public Networker(Kernel kernel) { super(Networker.class.getSimpleName(), kernel);

this.networkState = NETWORK_UNDEFINED;

public void run() { !nic.isLoopback());

Thread.sleep(Defaults.NETWORKER_INTERVAL);

} catch (InterruptedException ignored) { synchronized (this) { @Override public synchronized void activate() { Thread self = new Thread(this);

self.start();

@Override public synchronized void deactivate() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

import java.sql.Statement;

import java.util.Arrays;

import java.util.LinkedList;

import java.util.Queue;

import org.apache.log4j.Logger;

import com.googlecode.snoopyd.Defaults;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.core.state.ActiveState;

import com.googlecode.snoopyd.core.state.KernelListener;

import com.googlecode.snoopyd.core.state.KernelState;

public class Resulter extends AbstractDriver implements Driver, Startable, private static Logger logger = Logger.getLogger(Resulter.class);

public static class Result { public Result(String hostname, String osname, String module, String[] result) private Connection connection;

private Queue pool;

private boolean started;

public Resulter(Kernel kernel) { super(Resulter.class.getSimpleName(), kernel);

this.pool = new LinkedList();

public synchronized void store(String hostname, String osname, String module, logger.debug("storing result " + Arrays.toString(result));

pool.offer(new Result(hostname, osname, module, result));

if (pool.size() > Defaults.RESULTER_THRESHHOLD) { public synchronized void start() { logger.debug("starting " + name);

kernel.configuration().getProperty("connectionstring");

logger.debug("use connection url: " + connectionurl);

Class.forName("com.mysql.jdbc.Driver");

connection = DriverManager.getConnection(connectionurl);

} catch (ClassNotFoundException ex) { } catch (SQLException ex) { logger.error(ex.getMessage());

Thread self = new Thread(this, Defaults.RESULTER_THREAD_NAME);

self.start();

@Override public synchronized void stop() { logger.debug("stoping " + name);

} catch (SQLException ex) { } catch (NullPointerException ex) { started = false;

} catch (InterruptedException e) { logger.warn(e.getMessage());

@Override public synchronized boolean started() { return started;

@Override public synchronized void restart() { logger.debug("restarting " + name);

@Override public void run() { \"%s\", \"%s\", \"%s\");", result.osname(), result.hostname(), result.module(), sb.toString()));

public void stateChanged(KernelState currentState) { if (currentState instanceof ActiveState) { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.OutputStreamWriter;

import java.util.ArrayList;

import java.util.Arrays;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import java.util.Timer;

import java.util.TimerTask;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.parsers.ParserConfigurationException;

import javax.xml.transform.OutputKeys;

import javax.xml.transform.Transformer;

import javax.xml.transform.TransformerConfigurationException;

import javax.xml.transform.TransformerException;

import javax.xml.transform.TransformerFactory;

import javax.xml.transform.dom.DOMSource;

import javax.xml.transform.stream.StreamResult;

import org.apache.log4j.Logger;

import org.w3c.dom.Document;

import org.w3c.dom.DocumentType;

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

import org.xml.sax.SAXException;

import com.googlecode.snoopyd.Defaults;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.core.event.ScheduleTimeComeEvent;

import com.googlecode.snoopyd.core.event.ScheduleUpdatedEvent;

import com.googlecode.snoopyd.core.state.ActiveState;

import com.googlecode.snoopyd.core.state.KernelListener;

import com.googlecode.snoopyd.core.state.KernelState;

import com.googlecode.snoopyd.util.Identities;

public class Scheduler extends AbstractDriver implements Driver, Startable, public static enum ScheduleState { public static class Schedule { public Map statetable() { public Map paramstable() { private static Logger logger = Logger.getLogger(Scheduler.class);

private Schedule self;

private HashMap childs;

private Map timers;

private boolean started;

public Scheduler(Kernel kernel) { super(Scheduler.class.getSimpleName(), kernel);

this.self = new Schedule();

this.childs = new HashMap();

this.timers = new HashMap();

loadScheduleConfig();

public void synchronize(Ice.Identity identity, ISchedulerPrx remoteScheduler) { logger.debug("synchronize shceduler with " Schedule childSchedule = new Schedule();

Map remoteTimetable = remoteScheduler.timetable();

Map remoteStatetable = remoteScheduler.statetable();

Map remoteParamtable = remoteScheduler.paramtable();

for (String muid : remoteTimetable.keySet()) { for (String time : remoteTimetable.get(muid).split(";")) { childSchedule.timetable().put(muid, times);

for (String muid : remoteStatetable.keySet()) { if (remoteStatetable.get(muid).equals("ON")) { childSchedule.statetable().put(muid, ScheduleState.ON);

childSchedule.statetable().put(muid, ScheduleState.OFF);

for (String muid : remoteParamtable.keySet()) { for (String param : remoteParamtable.get(muid).split(";")) { childSchedule.paramstable().put(muid, params);

childs.put(identity, childSchedule);

public void schedule(String muid, long[] delays, String[] params) { if (self.timetable().containsKey(muid)) { self.timetable().get(muid).add(delay);

self.timetable().put(muid, new ArrayList());

self.timetable().get(muid).add(delay);

self.paramstable().put(muid, Arrays.asList(params));

self.statetable().put(muid, ScheduleState.ON);

kernel.handle(new ScheduleUpdatedEvent());

public void unschedule(String muid) throws ModuleNotFoundException { kernel.handle(new ScheduleUpdatedEvent());

public void force(Ice.Identity identity, String muid, String[] params) { kernel.handle(new ScheduleTimeComeEvent(identity, muid, params));

public Map timetable() { Map result = new HashMap();

for (String muid : self.timetable().keySet()) { StringBuilder sb = new StringBuilder();

for (Long time : self.timetable().get(muid)) { result.put(muid, sb.toString());

return result;

public Map statetable() { Map result = new HashMap();

for (String muid : self.statetable().keySet()) { result.put(muid, self.statetable().get(muid).toString());

return result;

public Map paramtable() { Map result = new HashMap();

for (String muid : self.paramstable().keySet()) { StringBuilder sb = new StringBuilder();

for (String param : self.paramstable().get(muid)) { result.put(muid, sb.toString());

return result;

public void toogle(String muid) { ScheduleState state = self.statetable().get(muid);

if (state == ScheduleState.OFF) { self.statetable().put(muid, ScheduleState.ON);

self.statetable().put(muid, ScheduleState.OFF);

kernel.handle(new ScheduleUpdatedEvent());

public void cancel(Ice.Identity identity) { logger.debug("cancel scheduing for " + Identities.toString(identity));

childs.remove(identity);

@Override public synchronized void start() { logger.debug("starting " + name);

@Override public synchronized void stop() { logger.debug("stoping " + name);

for (String muid : timers.keySet()) { timers.get(muid).cancel();

@Override public synchronized boolean started() { public synchronized void restart() { logger.debug("restarting " + name);

public void stateChanged(KernelState currentState) { if (currentState instanceof ActiveState) { public void activate() { loadScheduleConfig();

public void deactivate() { saveScheduleConfig();

private void update() { logger.debug("updating scheduler");

Identities.toString(identity));

ScheduleState.ON) { String[childSchedule.paramstable().get(muid).size()]);

childSchedule.timetable().get(muid)) { ScheduleTimeComeEvent( fprms));

private void loadScheduleConfig() { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

Document dom = db.parse(new File(kernel.properties().getProperty( NodeList modules = root.getElementsByTagName("module");

self.timetable().put(muid, delaysList);

self.paramstable().put(muid, paramsList);

} catch (ParserConfigurationException ex) { } catch (IOException ex) { } catch (SAXException ex) { private void saveScheduleConfig() { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

DocumentBuilder db = dbf.newDocumentBuilder();

Element root = doc.createElement("modules");

for (String muid: self.timetable().keySet()) { Element module = doc.createElement("module");

if (self.statetable().get(muid) == ScheduleState.ON) { Element schedule = doc.createElement("schedule");

Element params = doc.createElement("params");

for (String value: self.paramstable().get(muid)) { TransformerFactory transfac = TransformerFactory.newInstance();

Transformer trans = transfac.newTransformer();

trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");

trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");

trans.setOutputProperty(OutputKeys.STANDALONE, "no");

trans.setOutputProperty(OutputKeys.INDENT, "yes");

DocumentType dt = doc.getDoctype();

trans.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, pub);

trans.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, dt.getSystemId());

OutputStreamWriter sw = new OutputStreamWriter(new FileOutputStream(new File(kernel.properties().getProperty( StreamResult result = new StreamResult(sw);

DOMSource source = new DOMSource(doc);

trans.transform(source, result);

} catch (ParserConfigurationException ex) { } catch (TransformerConfigurationException ex) { } catch (TransformerException ex) { } catch (FileNotFoundException ex) { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

import org.apache.log4j.Logger;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.core.event.ChildSessionRecivedEvent;

import com.googlecode.snoopyd.core.event.ParentSessionSendedEvent;

import com.googlecode.snoopyd.core.state.KernelListener;

import com.googlecode.snoopyd.core.state.KernelState;

import com.googlecode.snoopyd.session.IKernelSessionPrx;

import com.googlecode.snoopyd.session.IKernelSessionPrxHelper;

import com.googlecode.snoopyd.session.IUserSessionPrx;

import com.googlecode.snoopyd.session.IUserSessionPrxHelper;

import com.googlecode.snoopyd.session.KernelSession;

import com.googlecode.snoopyd.session.KernelSessionAdapter;

import com.googlecode.snoopyd.session.UserSession;

import com.googlecode.snoopyd.session.UserSessionAdapter;

public class Sessionier extends AbstractDriver implements Driver, private static Logger logger = Logger.getLogger(Sessionier.class);

public Sessionier(Kernel kernel) { super(Sessionier.class.getSimpleName(), kernel);

public IKernelSessionPrx createKernelSession(Ice.Identity identity, kernel.handle(new ChildSessionRecivedEvent(identity, selfSession));

IKernelSessionPrx remoteSession = IKernelSessionPrxHelper KernelSession(kernel))));

kernel.handle(new ParentSessionSendedEvent(kernel.identity(), remoteSession));

public IUserSessionPrx createUserSession(Ice.Identity identity, //kernel.handle(new ChildSessionRecivedEvent(identity, selfSession));

IUserSessionPrx remoteSession = IUserSessionPrxHelper //kernel.handle(new ChildSessionSendedEvent(identity, remoteSession));

public void stateChanged(KernelState currentState) { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.driver;

public interface Startable { public boolean started();

public void restart();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.session;

import com.googlecode.snoopyd.adapter.ModulerAdapter;

import com.googlecode.snoopyd.adapter.SchedulerAdapter;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.driver.IModulerPrx;

import com.googlecode.snoopyd.driver.IModulerPrxHelper;

import com.googlecode.snoopyd.driver.ISchedulerPrx;

import com.googlecode.snoopyd.driver.ISchedulerPrxHelper;

import com.googlecode.snoopyd.driver.Moduler;

import com.googlecode.snoopyd.driver.Scheduler;

public class KernelSession { private Kernel kernel;

public KernelSession(Kernel kernel) { public ISchedulerPrx scheduler() { ISchedulerPrx remoteScheduler = ISchedulerPrxHelper.uncheckedCast(kernel.primary().addWithUUID( public IModulerPrx moduler() { IModulerPrx remoteModuler = IModulerPrxHelper.uncheckedCast(kernel /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.session;

import Ice.Current;

import com.googlecode.snoopyd.driver.IModulerPrx;

import com.googlecode.snoopyd.driver.ISchedulerPrx;

public class KernelSessionAdapter extends _IKernelSessionDisp { private KernelSession kernelSession;

public KernelSessionAdapter(KernelSession kernelSession) { this.kernelSession = kernelSession;

public void destroy(Current current) { public void refresh(Current current) { public IModulerPrx moduler(Current current) { return kernelSession.moduler();

public ISchedulerPrx scheduler(Current current) { return kernelSession.scheduler();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.session;

import com.googlecode.snoopyd.adapter.ConfigurerAdapter;

import com.googlecode.snoopyd.adapter.ControllerAdapter;

import com.googlecode.snoopyd.adapter.HosterAdapter;

import com.googlecode.snoopyd.adapter.ModulerAdapter;

import com.googlecode.snoopyd.adapter.SchedulerAdapter;

import com.googlecode.snoopyd.core.Kernel;

import com.googlecode.snoopyd.driver.Configurer;

import com.googlecode.snoopyd.driver.Controller;

import com.googlecode.snoopyd.driver.Hoster;

import com.googlecode.snoopyd.driver.IConfigurerPrx;

import com.googlecode.snoopyd.driver.IConfigurerPrxHelper;

import com.googlecode.snoopyd.driver.IControllerPrx;

import com.googlecode.snoopyd.driver.IControllerPrxHelper;

import com.googlecode.snoopyd.driver.IHosterPrx;

import com.googlecode.snoopyd.driver.IHosterPrxHelper;

import com.googlecode.snoopyd.driver.IModulerPrx;

import com.googlecode.snoopyd.driver.IModulerPrxHelper;

import com.googlecode.snoopyd.driver.ISchedulerPrx;

import com.googlecode.snoopyd.driver.ISchedulerPrxHelper;

import com.googlecode.snoopyd.driver.Moduler;

import com.googlecode.snoopyd.driver.Scheduler;

public class UserSession { private Kernel kernel;

public UserSession(Kernel kernel) { public IHosterPrx hoster() { IHosterPrx remoteHoster = IHosterPrxHelper public IControllerPrx controller() { IControllerPrx remoteController = IControllerPrxHelper.uncheckedCast(kernel.primary().addWithUUID( return remoteController;

public IModulerPrx moduler() { IModulerPrx remoteModuler = IModulerPrxHelper.uncheckedCast(kernel public IConfigurerPrx configurer() { IConfigurerPrx remoteConfigurer = IConfigurerPrxHelper.uncheckedCast(kernel.primary().addWithUUID( return remoteConfigurer;

public ISchedulerPrx scheduler() { ISchedulerPrx remoteScheduler = ISchedulerPrxHelper.uncheckedCast(kernel.primary().addWithUUID( /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.session;

import com.googlecode.snoopyd.driver.IConfigurerPrx;

import com.googlecode.snoopyd.driver.IControllerPrx;

import com.googlecode.snoopyd.driver.IHosterPrx;

import com.googlecode.snoopyd.driver.IModulerPrx;

import com.googlecode.snoopyd.driver.ISchedulerPrx;

import Ice.Current;

public class UserSessionAdapter extends _IUserSessionDisp { private UserSession userSession;

public UserSessionAdapter(UserSession userSession) { public void destroy(Current current) { public void refresh(Current current) { public IHosterPrx hoster(Current current) { public IControllerPrx controller(Current current) { return userSession.controller();

public IModulerPrx moduler(Current current) { return userSession.moduler();

public IConfigurerPrx configurer(Current current) { return userSession.configurer();

public ISchedulerPrx scheduler(Current current) { return userSession.scheduler();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.module;

import java.util.UUID;

public abstract class AbstractModule implements Module { protected UUID uudi;

protected String name;

public AbstractModule(UUID uudi, String name) { public UUID uudi() { public String name() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.module;

public interface Module { public Object invoke(Object arg);

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.module;

import java.util.UUID;

public class PythonModule extends AbstractModule implements Module { public PythonModule(UUID uudi, String name) { public Object invoke(Object arg) { // TODO Auto-generated method stub /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.adapter;

import com.googlecode.snoopyd.driver.Driver;

public interface Adapter { public Driver driver();

public String name();

public Ice.Identity identity();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.adapter;

import java.util.Map;

import Ice.Current;

import com.googlecode.snoopyd.driver.Configurer;

import com.googlecode.snoopyd.driver._IConfigurerDisp;

public class ConfigurerAdapter extends _IConfigurerDisp { private Configurer configurer;

public ConfigurerAdapter(Configurer configurer) { this.configurer = configurer;

public void reconfigure(Map configuration, Current current) { configurer.reconfigure(configuration);

public Map configuration(Current current) { return configurer.configuration();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.adapter;

import Ice.Current;

import com.googlecode.snoopyd.driver.Controller;

import com.googlecode.snoopyd.driver._IControllerDisp;

public class ControllerAdapter extends _IControllerDisp { private Controller controller;

public ControllerAdapter(Controller controller) { this.controller = controller;

public void shutdown(Current current) { controller.shutdown();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.adapter;

import org.apache.log4j.Logger;

import Ice.Current;

import Ice.Identity;

import com.googlecode.snoopyd.driver.Discoverer;

import com.googlecode.snoopyd.driver.Driver;

import com.googlecode.snoopyd.driver._IDiscovererDisp;

public class DiscovererAdapter extends _IDiscovererDisp implements Adapter { private static Logger logger = Logger.getLogger(DiscovererAdapter.class);

private String name;

private Ice.Identity identity;

private Discoverer discoverer;

public DiscovererAdapter(Ice.Identity identity, Discoverer discoverer) { this.discoverer = discoverer;

this.name = DiscovererAdapter.class.getSimpleName();

public void discover(Ice.Identity identity, Current current) { discoverer.discover(identity, current.ctx);

public Driver driver() { public String name() { public Identity identity() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.adapter;

import java.util.Map;

import Ice.Current;

import com.googlecode.snoopyd.driver.Hoster;

import com.googlecode.snoopyd.driver._IHosterDisp;

public class HosterAdapter extends _IHosterDisp { private Hoster hoster;

public HosterAdapter(Hoster hoster) { public Map context(Current current) { return hoster.context();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.adapter;

import java.util.Map;

import Ice.Current;

import com.googlecode.snoopyd.driver.Moduler;

import com.googlecode.snoopyd.driver._IModulerDisp;

import com.googlecode.snoopymm.ModuleNotFoundException;

public class ModulerAdapter extends _IModulerDisp { private Moduler moduler;

public ModulerAdapter(Moduler moduler) { public Map fetch(Current current) { public void deploy(String muid, String code, Current current) { moduler.deploy(muid, code);

public void undeploy(String muid, Current current) { } catch (ModuleNotFoundException ex) { public String[] launch(String muid, String[] params, Current current) throws com.googlecode.snoopyd.driver.ModuleNotFoundException { return moduler.launch(muid, params);

public void force(String muid, String[] params, Current current) { moduler.force(muid, params);

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.adapter;

import java.util.Map;

import Ice.Current;

import Ice.Identity;

import com.googlecode.snoopyd.driver.ISchedulerPrx;

import com.googlecode.snoopyd.driver.ModuleNotFoundException;

import com.googlecode.snoopyd.driver.Scheduler;

import com.googlecode.snoopyd.driver._ISchedulerDisp;

public class SchedulerAdapter extends _ISchedulerDisp { private Scheduler scheduler;

public SchedulerAdapter(Scheduler scheduler) { public Map timetable(Current current) { return scheduler.timetable();

public Map statetable(Current current) { return scheduler.statetable();

public void schedule(String muid, long[] delays, String[] params, scheduler.schedule(muid, delays, params);

public void unschedule(String muid, Current current) scheduler.unschedule(muid);

public void toogle(String muid, Current current) { public void synchronize(Identity identity, ISchedulerPrx remoteScheduler, scheduler.synchronize(identity, remoteScheduler);

public Map paramtable(Current current) { return scheduler.paramtable();

public void force(Identity identity, String muid, String[] params, scheduler.force(identity, muid, params);

package com.googlecode.snoopyd.adapter;

import org.apache.log4j.Logger;

import Ice.Current;

import Ice.Identity;

import com.googlecode.snoopyd.driver.Driver;

import com.googlecode.snoopyd.driver.Sessionier;

import com.googlecode.snoopyd.driver._ISessionierDisp;

import com.googlecode.snoopyd.session.IKernelSessionPrx;

import com.googlecode.snoopyd.session.IUserSessionPrx;

public class SessionierAdapter extends _ISessionierDisp implements Adapter { private static Logger logger = Logger.getLogger(SessionierAdapter.class);

private Ice.Identity identity;

private Sessionier sessionier;

public SessionierAdapter(Identity identity, Sessionier sessionier) { this.name = SessionierAdapter.class.getSimpleName();

public IKernelSessionPrx createKernelSession(Identity identity, IKernelSessionPrx selfSession, Current current) { return sessionier.createKernelSession(identity, selfSession);

public IUserSessionPrx createUserSession(Identity identity, return sessionier.createUserSession(identity, selfSession);

public Driver driver() { public Identity identity() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.config;

import java.io.Serializable;

public class Configuration implements Serializable { public static class ConfigurationBuilder { public ConfigurationBuilder rate(int rate) { public Configuration build() { public final int rate;

public Configuration(int rate) { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.config;

public class ConfigurationManager { public ConfigurationManager() { /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopyd.util;

import Ice.Identity;

public final class Identities { public static Identity randomIdentity(String domain) { return new Identity(java.util.UUID.randomUUID().toString(), domain);

public static String toString(Identity identity) { return identity.category + "/" + identity.name;

public static Identity clone(Identity identity) { public static Identity stringToIdentity(String identity) { String args[] = identity.split("/");

public static boolean equals(Identity id1, Identity id2) { return id1.name.equals(id2.name) && id1.category.equals(id2.category);

public static Identity xor(Identity id1, Identity id2) { // ex: 154d2630-fafd-4bcb-9cac-dec42ec4ba9c if (!id1.category.equals(id2.category)) { domain");

String id1Part[] = id1.name.split("-");

String id2Part[] = id2.name.split("-");

String resultPart[] = new String[5];

resultPart[0] = Long.toHexString(Long.valueOf(id1Part[0], 16) ^ Long.valueOf(id2Part[0], 16));

while (resultPart[0].length() < 8) { resultPart[0] = "0" + resultPart[0]; } resultPart[1] = Long.toHexString(Long.valueOf(id1Part[1], 16) ^ Long.valueOf(id2Part[1], 16));

while (resultPart[1].length() < 4) { resultPart[1] = "0" + resultPart[1]; } resultPart[2] = Long.toHexString(Long.valueOf(id1Part[2], 16) ^ Long.valueOf(id2Part[2], 16));

while (resultPart[2].length() < 4) { resultPart[2] = "0" + resultPart[2]; } resultPart[3] = Long.toHexString(Long.valueOf(id1Part[3], 16) ^ Long.valueOf(id2Part[3], 16));

while (resultPart[3].length() < 4) { resultPart[3] = "0" + resultPart[3]; } resultPart[4] = Long.toHexString(Long.valueOf(id1Part[4], 16) ^ Long.valueOf(id2Part[4], 16));

while (resultPart[4].length() < 12) { resultPart[4] = "0" + resultPart[4]; } String result = resultPart[0] + "-" + resultPart[1] + "-" + resultPart[2] + "-" + resultPart[3] + "-" + resultPart[4];

return new Identity(result, id1.category);

@echo off rem rem Copyrigth 2011, Snoopy Project rem set CP=lib/snoopyd.jar;lib/log4jjar;lib/Ice.jar;config/log4j.properies;lib/sigar.jar;lib/mysql-connector-javabin.jar;

set DEFINES=-Dsnoopyd.configuration=config/snoopyd.conf Dlog4j.configuration=config/log4j.properties set LIB=native/;

set ENTRY_POINT=com.googlecode.snoopyd.Launcher java -Xms64m -Xmx128m -Xss64m -classpath %CP% -Djava.library.path=%LIB% %DEFINES% %ENTRY_POINT% #!/bin/sh # Copyrigth 2011, Snoopy Project CP=lib/snoopyd.jar;lib/log4j-1.2.15.jar;lib/Ice.jar;config/log4j.properies;lib/sigar.jar;

DEFINES=-Dsnoopyd.configuration=config/snoopyd.conf Dlog4j.configuration=config/log4j.properties LIB=lib/;

ENTRY_POINT=com.googlecode.snoopyd.Launcher java -Xms64m -Xmx128m -Xss64m -classpath $CP -Djava.library.path=$LIB $DEFINES $ENTRY_POINT log4j.rootLogger=DEBUG, FILE, CONSOLE log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern= %c - %m%n log4j.appender.FILE=org.apache.log4j.RollingFileAppender log4j.appender.FILE.File=log/snoopyd.log log4j.appender.FILE.MaxFileSize=2MB log4j.appender.FILE.MaxBackupIndex= log4j.appender.FILE.layout=org.apache.log4j.PatternLayout log4j.appender.FILE.layout.ConversionPattern= %c - %m%n log4j.logger.com.googlecode.snoopyd.driver.Discoverer=DEBUG log4j.logger.com.googlecode.snoopyd.driver.Aliver=DEBUG log4j.logger.com.googlecode.snoopyd.driver.Networker=DEBUG log4j.logger.com.googlecode.snoopyd.driver.Sessionier=DEBUG Панель управления // ********************************************************************** // Copyright 2011 Snoopy Project // Licensed under the Apache License, Version 2.0 (the "License");

// You may not use this file except in compliance with the License.

// You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2. // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

// See the License for the specific language governing permissions and // limitations under the License.

// ********************************************************************** #ifndef SNOOPYD_ICE #define SNOOPYD_ICE #include module com { module googlecode { module snoopycp { }; }; };

#endif /** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopycp;

import com.googlecode.snoopycp.core.Snoopycp;

import javax.swing.JOptionPane;

public class Launcher { public static void main(String args[]) { Snoopycp snoopycp = new Snoopycp();

status = snoopycp.main(Defaults.APP_NAME, args, System.getProperty("snoopycp.configuration", Defaults.DEFAULT_CONFIGURATION));

} catch (Ice.FileException ex) { System.out.println(ex.getMessage());

JOptionPane.showMessageDialog(null, e.getMessage());

System.exit(status);

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopycp;

public final class Defaults { public static final String APP_NAME = "snoopycp";

public static final String APP_VER = "0.1";

public static final String DEFAULT_CONFIGURATION = "snoopycp.conf";

public static final String DEFAULT_ADAPTER_NAME = "Adapter";

// path to icons, pics and other staff public static final String PATH_TO_SHARE = "/com/googlecode/snoopycp/share/";

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopycp.core;

import com.googlecode.snoopycp.controller.Coordinator;

import com.googlecode.snoopycp.controller.DomainController;

import com.googlecode.snoopycp.ui.MainFrame;

import org.apache.log4j.Logger;

public class Snoopycp extends Ice.Application { public static Logger logger = Logger.getLogger(Snoopycp.class);

public static final int EXIT_SUCCESS = 0;

public static final int EXIT_FAILURE = 999;

public static class ShutdownHook extends Thread { private Coordinator coordinator;

public ShutdownHook(Coordinator coordinator) { this.coordinator = coordinator;

coordinator.terminate();

@Override public int run(String[] args) { Ice.Communicator communicator = communicator();

Ice.Properties properties = communicator.getProperties();

Domain domain = new Domain(communicator, properties.getProperty("Snoopy.Domain"));

DomainController controller = new DomainController(domain);

MainFrame view = new MainFrame(controller);

Coordinator coordinator = new Coordinator(domain, view);

setInterruptHook(new ShutdownHook(coordinator));

coordinator.launch();

return EXIT_SUCCESS;

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopycp.core;

import com.googlecode.snoopycp.util.Identities;

import java.util.Map;

import org.apache.log4j.Logger;

public class Discoverer { public static Logger logger = Logger.getLogger(Discoverer.class);

private Domain domain;

public Discoverer(Domain domain) { this.domain = domain;

public void discover(Ice.Identity identity, Map context) { logger.debug("discoverer recieved from " + Identities.toString(identity));

domain.cacheit(identity, context);

//System.out.println("OS type: " + context.get("os"));

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopycp.core;

import Ice.Current;

import Ice.Identity;

public class DiscovererAdapter extends _IDiscovererDisp { private Discoverer discoverer;

public DiscovererAdapter(Discoverer discoverer) { this.discoverer = discoverer;

public void discover(Identity identity, Current current) { discoverer.discover(identity, current.ctx);

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopycp.core;

import Ice.Communicator;

import Ice.Identity;

import com.googlecode.snoopycp.Defaults;

import com.googlecode.snoopycp.util.Identities;

import com.googlecode.snoopyd.driver.IConfigurerPrx;

import com.googlecode.snoopyd.driver.IControllerPrx;

import com.googlecode.snoopyd.driver.IHosterPrx;

import com.googlecode.snoopyd.driver.IModulerPrx;

import com.googlecode.snoopyd.driver.ISchedulerPrx;

import com.googlecode.snoopyd.driver.ISessionierPrx;

import com.googlecode.snoopyd.driver.ISessionierPrxHelper;

import com.googlecode.snoopyd.session.IUserSessionPrx;

import java.util.Collections;

import java.util.HashMap;

import java.util.HashSet;

import java.util.Map;

import java.util.Observable;

import java.util.Set;

import java.util.concurrent.ConcurrentHashMap;

import org.apache.log4j.Logger;

public class Domain extends Observable implements Runnable { public static Logger logger = Logger.getLogger(Domain.class);

private Ice.Identity identity;

private Ice.Communicator communicator;

private String name;

private Ice.ObjectAdapter adapter;

private Set hosts;

private Map enviroment;

private Map life;

private Map cache;

private Map hosters;

private Map sessions;

private Map controllers;

private Map hashes;

private Map osPull;

private Map modulers;

private Map schedulers;

private Map modulesStatus;

private Map modulesName;

private Map configurers;

public Domain(Communicator communicator, String name) { this.identity = Identities.randomIdentity(name);

this.communicator = communicator;

this.hosts = new HashSet();

this.enviroment = new HashMap();

this.life = new HashMap();

this.cache = new ConcurrentHashMap();

this.sessions = new ConcurrentHashMap();

this.controllers = new ConcurrentHashMap();

this.hosters = new ConcurrentHashMap();

this.osPull = new ConcurrentHashMap();

this.modulers = new ConcurrentHashMap();

this.schedulers = new ConcurrentHashMap();

this.configurers = new ConcurrentHashMap();

this.modulesStatus = new ConcurrentHashMap();

this.modulesName = new ConcurrentHashMap();

this.hashes = new HashMap();

this.adapter = communicator.createObjectAdapter(Defaults.DEFAULT_ADAPTER_NAME);

this.adapter.add(new DiscovererAdapter(new Discoverer(this)), communicator.stringToIdentity(Discoverer.class.getSimpleName()));

this.adapter.activate();

Thread self = new Thread(this);

public String name() { public Ice.Identity identity() { public Ice.Communicator communicator() { return communicator;

public void cacheit(Ice.Identity identity, Map context) { synchronized (this) { cache.put(identity, context);

life.put(identity, System.currentTimeMillis());

hosts.add(context.get("hostname"));

enviroment.put(context.get("hostname"), identity);

osPull.put(identity, context.get("os"));

context.get("primary");

ISessionierPrxHelper.checkedCast(communicator.stringToProxy(proxy));

logger.debug("Checked cast to remote session");

remoteSessionier.createUserSession(identity(), null);

sessions.put(identity, remoteSessionPrx);

IHosterPrx remoteHoster = remoteSessionPrx.hoster();

IControllerPrx remoteController = remoteSessionPrx.controller();

controllers.put(identity, remoteController);

IModulerPrx remoteModuler = remoteSessionPrx.moduler();

modulers.put(identity, remoteModuler);

modulesName.put(identity, remoteModuler.fetch());

ISchedulerPrx remoteScheduler = remoteSessionPrx.scheduler();

schedulers.put(identity, remoteScheduler);

schedulers.get(identity).ice_ping();

modulesStatus.put(identity, schedulers.get(identity).statetable());

IConfigurerPrx remoteConfigurer = remoteSessionPrx.configurer();

configurers.put(identity, remoteConfigurer);

} catch (Ice.ConnectionRefusedException ex) { logger.warn("Problem with fetch information about remote node: " + ex.getMessage());

logger.debug("New host: " + context.get("hostname") + " was added");

logger.debug(newSize + " hosts in domain");

enviroment.get(context.get("hostname")) == null) { enviroment.put(context.get("hostname"), identity);

context.hashCode()) { hashes.put(identity, context.hashCode());

public Set hosts() { public Map osPull() { public boolean isDied(Ice.Identity identity) { return !enviroment.containsValue(identity);

public Map enviroment() { return Collections.unmodifiableMap(enviroment);

public Map cache(Ice.Identity identity) { return cache.get(identity);

public IHosterPrx hoster(Ice.Identity identity) { return hosters.get(identity);

public IModulerPrx moduler(Ice.Identity _identity) { return modulers.get(_identity);

public ISchedulerPrx scheduler(Ice.Identity _identity) { return schedulers.get(_identity);

public IControllerPrx controller(Ice.Identity identity) { return controllers.get(identity);

public IConfigurerPrx configurer(Ice.Identity identity) { return configurers.get(identity);

public Map moduleStatus(Ice.Identity _ident) { return modulesStatus.get(_ident);

public Map moduleName(Ice.Identity _ident) { return modulesName.get(_ident);

public IUserSessionPrx session(Ice.Identity identity) { return sessions.get(identity);

public void updateModules(Ice.Identity _ident) { this.sessions.get(_ident).ice_ping();

this.sessions.get(_ident).moduler().fetch();

this.modulesName.remove(_ident);

this.modulesName.put(_ident, map);

schedulers.get(_ident).ice_ping();

modulesStatus.remove(_ident);

modulesStatus.put(_ident, schedulers.get(_ident).statetable());

logger.debug("Modules list updated");

} catch (Ice.ConnectionRefusedException ex) { logger.warn("Updating modules list failed: " + ex.getMessage());

@Override public void run() { //modulesStatus.clear();

if (System.currentTimeMillis() - life.get(id) > 10000) { from domain");

} catch (InterruptedException ex) { logger.warn("Thread cann`t fall into dream: " + ex.getMessage());

public void notifyObserver() { notifyObservers();

logger.debug("Domain is changed. Observers notified.");

public void removeHost(String _hostname) { this.hosts.remove(_hostname);

logger.debug("Host: " + _hostname + " was removed. " + hosts.size());

notifyObserver();

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopycp.controller;

import com.googlecode.snoopycp.core.Domain;

import com.googlecode.snoopycp.model.GraphModel;

import com.googlecode.snoopycp.model.TableModel;

import com.googlecode.snoopycp.model.TreeModel;

import java.awt.Color;

import java.awt.Paint;

import org.apache.commons.collections15.Transformer;

public class DomainController { private Domain domain;

public DomainController(Domain domain) { this.domain = domain;

public TableModel createTableModel() { return new TableModel(domain);

public TreeModel createTreeModel() { return new TreeModel(domain);

public GraphModel createGraphModel() { return new GraphModel(domain);

public Transformer createLabelTransformer() { return new Transformer() { public String transform(String vertex) { public Transformer createFillTransformer() { return new Transformer() { public Paint transform(String vertex) { if (domain.enviroment().get(vertex) == null) { Ice.Identity identity = domain.enviroment().get(vertex);

String state = domain.cache(identity).get("state");

/** * Copyright 2011 Snoopy Project * Licensed under the Apache License, Version 2.0 (the "License");

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and * limitations under the License.

package com.googlecode.snoopycp.controller;



Pages:     | 1 | 2 || 4 | 5 |


Похожие работы:

«Записи выполняются и используются в СО 1.004 СО 6.018 Предоставляется в СО 1.023. Федеральное государственное бюджетноеобразовательное учреждение высшего профессионального образования Саратовский государственный аграрный университет имени Н.И. Вавилова Факультет экономики и менеджмента СОГЛАСОВАНО УТВЕРЖДАЮ Декан факультета Проректор по учебной работе Дудникова Е.Б. Ларионов С.В. _ г. _ г. РАБОЧАЯ (МОДУЛЬНАЯ) ПРОГРАММА Дисциплина Маркетинговые коммуникации Для специальности 080111.65 Маркетинг...»

«Министерство образования Республики Беларусь Учреждение образования Международный государственный экологический университет имени А. Д. Сахарова Факультет экологической медицины Кафедра биологии человека и экологии Бученков И.Э. Растительные ресурсы Беларуси, рациональное использование и охрана Краткий курс лекций Минск 2012 УДК 581.9 (100) ББК Б Рекомендовано к изданию НМС МГЭУ им. А.Д. Сахарова (протокол № от 2012 г.) Авторы: к.с.-х.н., доцент, доцент кафедры биологии человека и экологии...»

«НОУ МФПУ Синергия УТВЕРЖДАЮ сполнительный директор В.ГЛобов (расшифровка подписи) ПОЛОЖЕНИЕ О СТРУКТУРНОМ ПОДРАЗДЕЛЕНИИ Кафедра факультета Спортивного менеджмента 1. Общие положения 1. Кафедра факультета Спортивного менеджмента (Далее - кафедра) является самостоятельным структурным подразделением НОУ МФПУ Синергия (Далее Университет). 2. Кафедра создается и ликвидируется приказом Исполнительного директора НОУ МФПУ Синергия. 3. Кафедра подчиняется непосредственно Исполнительному директору НОУ...»

«Приложение 3: Рабочая программа обязательной дисциплины Иностранный язык ФЕДЕРАЛЬНОЕ ГОСУДАРСТВЕННОЕ БЮДЖЕТНОЕ ОБРАЗОВАТЕЛЬНОЕ УЧРЕЖДЕНИЕ ВЫСШЕГО ПРОФЕССИОНАЛЬНОГО ОБРАЗОВАНИЯ ПЯТИГОРСКИЙ ГОСУДАРСТВЕННЫЙ ЛИНГВИСТИЧЕСКИЙ УНИВЕРСИТЕТ Утверждаю Проректор по научной работе и развитию интеллектуального потенциала университета профессор З.А. Заврумов _2012 г. Аспирантура по специальности 08.00.01 Экономическая теория отрасль науки: 08.00.00 Экономические науки Дисциплина: Иностранный язык Статус...»

«от 22 ноября 2011 г. № 327 г. Владикавказ О Республиканской целевой программе Сохранение объектов культурного наследия Республики Северная Осетия-Алания на 2012-2014 годы В целях обеспечения условий для сохранения объектов культурного наследия в интересах настоящего и будущего поколений, эффективного использования объектов культурного наследия в современных условиях, популяризации объектов культурного наследия Правительство Республики Северная Осетия-Алания п о с т а н о в л я е т: 1. Утвердить...»

«УТВЕРЖДАЮ Первый проректор по учебной работе ФГБОУ ВПО Алтайский государственный университет Е.С. Аничкин марта 2014 г. ПРОГРАММА вступительного испытания для поступающих на обучение по направлениям подготовки научнопедагогических кадров в аспирантуре: 37.06.01 Психологические науки, 39.06.01 Социологические науки, 41.06.01 Политические науки и регионоведение, 42.06.01 Средства массовой информации и информационно-библиотечное дело, 44.06.01 Образование и педагогические науки, 45.06.01...»

«МИНИСТЕРСТВО ОБРАЗОВАНИЯ И НАУКИ РОССИЙСКОЙ ФЕДЕРАЦИИ Ярославский государственный университет им. П.Г. Демидова Юридический факультет УТВЕРЖДАЮ Проректор по развитию образования _Е.В. Сапир _2012 Рабочая программа дисциплины послевузовского профессионального образования (аспирантура) Актуальные проблемы уголовного права по специальности научных работников 12.00.08 Уголовное право и криминология; уголовно исполнительное право Ярославль 2012 2 1. Цели освоения дисциплины Целями освоения...»

«ISSN 0536 – 1036. ИВУЗ. Лесной журнал. 2006. № 4 84 УДК 577.15: 674.815. Д.А. Кадималиев, В.В. Ревин, Н.А. Атыкян, В.В. Шутова Кадималиев Давуд Алиевич родился в 1952 г., окончил Мордовский государственный университет, доктор биологических наук, профессор кафедры биотехнологии Мордовского госуниверситета. Автор более 50 научных работ в области биотехнологии композиционных материалов, иммобилизованных биокатализаторов. Ревин Виктор Васильевич родился в 1949 г., окончил Мордовский государственный...»

«МИНИСТЕРСТВО СЕЛЬСКОГО ХОЗЯЙСТВА РОССИЙСКОЙ ФЕДЕРАЦИИ ФГОУ ВПО УЛЬЯНОВСКАЯ ГОСУДАРСТВЕННАЯ СЕЛЬСКОХОЗЯЙСТВЕННАЯ АКАДЕМИЯ ЭКОНОМИЧЕСКИЙ ФАКУЛЬТЕТ КАФЕДРА Экономика и управление на предприятиях АПК РАБОЧАЯ ПРОГРАММА ПО ДИСЦИПЛИНЕ “Формирование ассортимента” для студентов экономического факультета очного отделения специальности “ экономика и управление на предприятии АПК” Ульяновск 2009 2 1.Цель и задачи дисциплины Цель изучения дисциплины Формирование ассортимента - дать знания, необходимые для...»

«ВЫБОР И РАСЧЕТ АКУСТИЧЕСКИХ ПАРАМЕТРОВ ЗВУКОВОСПРОИЗВОДЯЩИХ УСТРОЙСТВ СИСТЕМ ОПОВЕЩЕНИЯ А. Пинаев к.т.н., доцент БГУИР, директор ОДО Авангардспецмонтаж, М. Альшевский с.н.с. НИИ ПБ и ЧС МЧС РБ О пределение необходимой мощности и уровня звукового давления акустиче ских устройств в системах оповещения всегда представляло значительную проб лему для проектировщиков. Некоторые производители систем оповещения, стараясь облегчить их труд, приводят всевозможные графики, таблицы или программы для...»

«АДМИНИСТРАЦИЯ ГОРОДА НИЖНЕГО НОВГОРОДА Муниципальное бюджетное образовательное учреждение гимназия № 184 1 Наш адрес: Ленина проспект, дом 61, корпус 6, город Нижний Новгород, 603090, метро Двигатель революции. Телефон: 258-15-42; 258-41-49. Факс: 258-15-42. E-mail: [email protected] Сайт: www.gymnasium184.3dn.ru Наш спецсчет для добровольных пожертвований: Получатель платежа: Департамент финансов города Нижнего Новгорода (МБОУ гимназия № 184) ИНН 5258026080 КПП 525801001 р/с...»

«Муниципальное бюджетное нетиповое общеобразовательное учреждение Гимназия № 62 МБ НОУ Гимназия №62 УТВЕРЖДАЮ Программа рекомендована к Директор МБ НОУ Гимназия № 62 работе педагогическим О.В.Колесникова_ советом _ 2013 г. Протокол №_ от Программа обсуждена и рекомендована к утверждению на заседании МО Протокол №_ от_ Технология РАБОЧАЯ УЧЕБНАЯ ПРОГРАММА 8класс (обслуживающий труд) Составитель: С.А.Жарова, учитель технологии Новокузнецк ФО-01-2012(01) Технология Рабочая учебная программа...»

«1. Пояснительная записка 1.1 Краткая характеристика дисциплины Дисциплина Музеи мира является дисциплиной специализации, обучающихся по специальности КУЛЬТУРАЛОГИЯ. Рабочая программа составлена в соответствии с ГОС ВПО. Программа включает тематический почасовой план, вопросы для самоподготовки, список рекомендованной литературы, периодических изданий, печатных и интернет - справочников и каталогов, словарь музееведческих терминов, критерии освоения курса и требований к зачету. Цели дисциплины:...»

«Софт для ПК. Прочие утилиты ABBYY FineReader 12 Professional ABBYY FineReader 12 Professional – программа для 4 490.распознавания текста, которая переводит изображения документов и любые типы PDF-файлов в электронные редактируемые форматы. Программа определяет и точно восстанавливает логическую структуру документа в его Номенклатурный код: электронной копии, позволяя забыть о перепечатывании 320258 текстов. Batch Picture Resizer Batch Picture Resizer поможет вам изменить размеры 349.большого...»

«ПРИМЕРНАЯ ПРОГРАММА ОСНОВНОГО ОБЩЕГО ОБРАЗОВАНИЯ по направлению ТЕХНОЛОГИЯ. ОБСЛУЖИВАЮЩИЙ ТРУД ПОЯСНИТЕЛЬНАЯ ЗАПИСКА Статус документа Примерная программа по направлению Технология. Обслуживающий труд. составлена на основе федерального компонента государственного стандарта основного общего образования. Примерная программа позволяет всем участникам образовательного процесса получить представление о целях, содержании, общей стратегии обучения, воспитания и развития учащихся средствами данного...»

«Приказ Министерства образования и науки РФ от 25 февраля 2009 г. N 59 Об утверждении Номенклатуры специальностей научных работников С изменениями и дополнениями от: 11 августа, 16 ноября 2009 г., 10 января 2012 г. В соответствии с подпунктом 5.2.11 Положения о Министерстве образования и науки Российской Федерации, утвержденного постановлением Правительства Российской Федерации от 15 июня 2004 г. N 280 (Собрание законодательства Российской Федерации, 2004, N 25, ст. 2562; 2005, N 15, ст. 1350;...»

«СТАТУС ДОКУМЕНТА Программа составлена на основании примерной программы начального общего образования (авторы - В.П.Канакина, В.Г.Горецкий), составленной в соответствии с Федеральным компонентом Государственного стандарта, утверждённым в 2004 г. приказом Минобразования РФ № 1089 от 05.03.2004. Программа соответствует основной образовательной программе и учебному плану ГБОУ СОШ № 900. Рабочая программа конкретизирует содержание предметных тем образовательного стандарта и дает примерное...»

«ТОГБОУ для детей-сирот и детей, оставшихся без попечения родителей Отъясская специальная (коррекционная) школа-интернат для детей с ограниченными возможностями здоровья РАССМОТРЕНО И РЕКОМЕНДОВАНО УТВЕРЖДЕНО на заседании педагогического совета приказом школы-интерната протокол № _ от № _ от _ _ 20_г _ 20г директор школы-интерната _ /Глушкин Н.А./ РАБОЧАЯ ПРОГРАММА по физике для 9 класса на 2011 – 2015 годы 2010 ПОЯСНИТЕЛЬНАЯ ЗАПИСКА Цели изучения физики: • освоение знаний о механических,...»

«Сабхаева Раджана Александровна, методист ГБОУ СПО Бурятский аграрный колледж им. М.Н. Ербанова, преподаватель экономических дисциплин Очирова Светлана Очировна, зам. директора по научнометодической работе ГБОУ СПО Бурятский аграрный колледж им. М.Н. Ербанова, преподаватель экономических дисциплин Рабочая тетрадь по учебной дисциплине Статистика используется для проведения практических занятий. В данной тетради содержится материал, необходимый для выполнения практических заданий, и задания,...»

«5-я международная конференция Решения 1С для корпоративных клиентов 8-16 июня 2013 года Доминиканская Республика Отель Barcelo Bavaro Palace Deluxe 5* 1С:Зарплата и управление персоналом 8 КОРП, ред. 3.0 — решение для автоматизации HR для корпораций и быстрорастущих компаний Концепция новой редакции и основные приоритеты Александр Толмачев методист, фирма 1С О чем пойдет речь. Особенности новой редакции – обобщение лучших практик гибкая настройка функциональности анализ структуры затрат на...»






 
2014 www.av.disus.ru - «Бесплатная электронная библиотека - Авторефераты, Диссертации, Монографии, Программы»

Материалы этого сайта размещены для ознакомления, все права принадлежат их авторам.
Если Вы не согласны с тем, что Ваш материал размещён на этом сайте, пожалуйста, напишите нам, мы в течении 1-2 рабочих дней удалим его.